【发布时间】:2019-02-13 11:08:09
【问题描述】:
我正在按照教程并尝试启动节点服务器,但我无法将其导入 Apollo 包中的函数
const {graphqlExpress, graphiqlExpress} = require('apollo-server-express'); // here i importing fucntions
const bodyParser = require('body-parser'); // import parser
const cors = require('cors'); // import cors
const express = require('express'); // import cors
const { makeExecutableSchema } = require('graphql-tools');
const port = 9000; // define port
const schema = makeExecutableSchema({typeDefs, resolvers}); // init shcema
const app = express();
app.use(cors(), bodyParser.json());
app.use('/graphql', graphqlExpress({schema})); // is not a function
app.use('/graphiql', graphiqlExpress({endpointUrl: '/graphql'})); // is not a function
app.listen(port, () => console.log(`Server is running on the port ${port}`));
当我启动服务器时如果由于“graphqlExpress 不是函数”而失败,并且当它发表评论并且服务器重新启动关于 graphiqlExpress 的相同事情时。也许我正在关注的教程已经过时并且apollo-server-express不再提供这样的功能?
【问题讨论】:
标签: javascript express graphql