Apollo graphql-tools
现在有Schema Stitching,这很棒 . 我想合并多个 endpoints 以生成类似于GraphQL Hub的模式,如下所示:
query { github: { ... } # GitHub Schema twitter: { ... } # Twitter Schema myOwnGraphqlSchema: { ... } }
如何做到这一点的最佳方法是什么?
GitHub问题:https://github.com/apollographql/graphql-tools/issues/439
叉在这里进行测试:https://launchpad.graphql.com/3xlrn31pv
谢谢 .
1 回答
Original answer:
这是一个解决方案(黑客?)我提出了,但可能有更好的方法来做到这一点:
使用
introspectSchema
和makeRemoteExecutableSchema
获取远程模式使用
printSchema
获取架构类型defs将printSchema收到的根typedef
Query
和Mutation
重命名为其他内容,例如GitHubQuery
和GitHubMutation
使用类型为
GitHubQuery
的github
字段创建根查询typedef创建
github
解析程序,该解析程序使用execute
方法在远程github模式中运行GitHubQuery
Source code: https://launchpad.graphql.com/3xlrn31pv