当我尝试将Apollo服务器集成到流星应用程序时,我会在尝试打开GraphIQL后立即获得错误。如果我创建一个Express应用并将其与webapp.connectHandlers
连接,并将Apollo Server放置在该快速应用程序的一条路线,工作中,但是它们不在" Meteor Way"中,我真的很想拥有,因为我会访问用户对象,授权等
错误,我在GraphIQL加载后立即看到它:
Error: Schema must be an instance of GraphQLSchema. Also ensure that there are not multiple versions of GraphQL installed in your node_modules directory
stacktrace:
at invariant (/Users/.../node_modules/graphql/jsutils/invariant.js:18:11)<br> at Object.validate (/Users/.../node_modules/graphql/validation/validate.js:59:72)<br> at doRunQuery (/Users/.../node_modules/apollo-server-core/dist/runQuery.js:88:38)<br> at /Users/.../node_modules/apollo-server-core/dist/runQuery.js:22:54<br> at /Users/.../.meteor/packages/promise/.0.10.0.borizy.o9z8++os+web.browser+web.cordova/npm/node_modules/meteor-promise/fiber_pool.js:43:40
服务器代码:
import {makeExecutableSchema} from 'graphql-tools';
import {typeDefs} from './schema';
import {resolvers} from './resolvers';
import { createApolloServer } from 'meteor/apollo';
export const schema = makeExecutableSchema({
typeDefs,
resolvers
});
createApolloServer({
schema
});
一切似乎都是合法的,并且可以与流星一起使用。是什么原因?我该如何修复?
meteor/apollo
的当前版本与最新的Apollo NPM软件包已过时。https://github.com/swydo/ddp-apollo是最新的,并以"流星方式"😊
还确保您的node_modules目录中没有多个版本的GraphQl
如果这是问题,它将通过
解决rm -rf node_modules/*
npm install