问题描述
- “Apollo Server 2 导出了所有的 graphql 工具,所以 makeExecutableSchema 等函数可以直接导入 来自阿波罗服务器。”
- "Apollo Server 能够接受已启用的架构 graphql-tools"
但是,我刚刚注意到我不能直接从 apollo-server 导入 stitchSchemas(我一直在从 @graphql-tools/stitch 使用它),并且我在问题上已经很长时间了没有道理。
Apollo 是否与stitchSchemas 一起工作?
解决方法
是的,您可以将 stitchSchemas
与 Apollo Server 一起使用,但您应该安装最新版本的 graphql-tools
并从 stichSchemas
而不是 graphql-tools
导入 apollo-server
.
您可以使用最新版本的 graphql-tools
来构建 GraphQLSchema
对象,无论是通过 stitchSchemas
、makeExecutableSchema
还是其他一些实用程序。然后,您可以使用此模式初始化 ApolloServer:
const server = new ApolloServer({ schema })