将阿波罗集成到流星应用程序



当我尝试将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> &nbsp; &nbsp;at Object.validate (/Users/.../node_modules/graphql/validation/validate.js:59:72)<br> &nbsp; &nbsp;at doRunQuery (/Users/.../node_modules/apollo-server-core/dist/runQuery.js:88:38)<br> &nbsp; &nbsp;at /Users/.../node_modules/apollo-server-core/dist/runQuery.js:22:54<br> &nbsp; &nbsp;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

最新更新