Does Apollo Server work with GraphQL Tools stitchSchemas?

冷暖自知 提交于 2021-01-07 01:33:16

问题


According to Apollo docs

  • "Apollo Server 2 exports all of graphql-tools, so makeExecutableSchema and other functions can be imported directly from Apollo Server."
  • "Apollo Server is able to accept a schema that has been enabled by graphql-tools"

However, I've just noticed I can't directly import stitchSchemas from apollo-server (I've been using it from @graphql-tools/stitch), and am hours deep in problems that aren't making sense.

Does Apollo work with stitchSchemas or not?


回答1:


Yes, you can use stitchSchemas with Apollo Server, but you should install the latest version of graphql-tools and import stichSchemas from graphql-tools instead of apollo-server.

You can use the latest version of graphql-tools to build a GraphQLSchema object, whether through stitchSchemas, makeExecutableSchema or some other utility. You can then initialize ApolloServer using this schema:

const server = new ApolloServer({ schema })


来源:https://stackoverflow.com/questions/65565586/does-apollo-server-work-with-graphql-tools-stitchschemas

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!