我试图部署运行节点JS在Heroku上的应用程序,它已成功部署,但操场上似乎并不工作。
我来解决此解决方案通过设置introspection: true
: https://github.com/apollographql/apollo-server/issues/1718但也似乎并不工作。
Heroku的日志
我的代码:
的package.json
{
"name": "travelindiaserver",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"clean": "rm -rf build && mkdir build",
"build-babel": "babel -d ./build ./src -s",
"build": "npm run clean && npm run build-babel",
"start": "npm run build && node ./build/index.js"
},
"author": "",
"license": "ISC",
"dependencies": {
"apollo-server-express": "^2.4.8",
"babel-preset-env": "^1.7.0",
"express": "^4.16.4",
"graphql": "^14.2.1"
},
"devDependencies": {
"babel-cli": "^6.26.0"
}
}
index.js
import express from "express";
import { ApolloServer } from "apollo-server-express";
import typeDefs from "./schema";
import resolvers from "./resolvers";
import models from "./models";
const app = express();
const server = new ApolloServer({
typeDefs,
resolvers,
context: { models },
introspection: true
});
server.applyMiddleware({ app });
const PORT = process.env.PORT || 5000;
app.listen(PORT, () =>
console.log(
`