【问题标题】:How can I add a share to GraphQL Bin option to my Apollo server playground?如何将共享到 GraphQL Bin 选项添加到我的 Apollo 服务器游乐场?
【发布时间】:2020-05-16 14:07:21
【问题描述】:

我正在使用 Apollo 服务器来实现一个 GraphQL API,它会自动给我一个 GraphQL Playground。根据GraphQL Playground docs,我应该拥有(或至少能够启用)一个“共享”功能,该功能将创建一个 GraphQL Bin 链接(例如https://graphqlbin.com/OksD),我可以将其发送给同事,以便他们可以查看和运行我的相同的查询。

很遗憾,Apollo 服务器开箱即用不提供此功能。如何启用此功能?如果这不可能,是否有另一种简单的方法可以让我从 GraphQL Playground 导出我的查询以供其他人导入? (我看到了“复制 curl”选项,但没有看到从 curl 导入的简单方法。)

【问题讨论】:

  • 有几个未解决的问题,例如this one

标签: graphql apollo-server prisma-graphql graphql-playground


【解决方案1】:

shareEnabled: true 添加到您的游乐场选项,例如

        const apolloServer = new ApolloServer({
                schema,
                debug: isDevelopment,
                introspection: isDevelopment,
                playground: {
                    shareEnabled: true,    
                },
        });

您可能还想修复 CORS 原始标头,允许来自 https://graphqlbin.com 的请求

【讨论】:

  • 这很好用。谢谢!你知道这是否包含在他们的文档中。我在 graphql-playground 自述文件中没有看到它。很高兴看到文档中的所有可用选项。
  • 我也很想知道这一切都记录在哪里。我在任何地方都没有找到它。
猜你喜欢
  • 2020-01-08
  • 2021-03-28
  • 2021-11-01
  • 2020-01-05
  • 1970-01-01
  • 1970-01-01
  • 2021-04-03
  • 2021-11-30
  • 1970-01-01
相关资源
最近更新 更多