你好,我在这里遇到麻烦
所以我想从Express转到Apollo服务器,所以我试图重新输入代码(模式)
我在index.js的根文件夹中有这行
const apolloServer = require('./apollo')
在此模块中,我具有架构和解析器,但主要问题是将typeDefs和解析器导出到根index.js
在package.json中,我有这个
{
"name": "server",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"dev": "babel-watch index.js"
},
"author": "",
"license": "ISC",
"dependencies": {
"apollo-server-express": "^2.4.8",
"cors": "^2.8.5",
"express": "^4.16.4",
"express-graphql": "^0.8.0",
"graphql": "^14.2.1",
"graphql-tools": "^4.0.4",
"lodash": "^4.17.11",
"mongoose": "^5.5.2"
},
"devDependencies": {
"@babel/cli": "^7.4.3",
"@babel/core": "^7.4.3",
"@babel/preset-env": "^7.4.3",
"babel-watch": "^7.0.0"
}
}
我有babel-cli用于新语法导出,但终端机提示
export const server = new ApolloServer({
^
TypeError: _apolloServerExpress.default is not a constructor
此行的代码是:
export const server = new ApolloServer({
typeDefs,
resolvers,
});
我尝试了一些来自堆栈或github的问题,但相同的结果请给我一种解决此问题的方法