【问题标题】:How to change websocket url in graphql-playground (subscriptions)如何在 graphql-playground 中更改 websocket url(订阅)
【发布时间】:2019-08-01 18:47:30
【问题描述】:

我想在graphql中更改graphql websocket端点,有人知道怎么做吗?

默认是ping

wss://localhost/graphql

我需要将其更改为推送器网址

谢谢 :-)

【问题讨论】:

  • 你在使用apollo-server-express吗?您能否提供更多关于您如何实施服务器的信息?

标签: graphql graphql-subscriptions


【解决方案1】:

如果您正在运行 GraphQL Playground 的独立实例,则 URL 将作为 prop 直接传递给组件:

<Playground
  endpoint="http://localhost/graphql"
  subscriptionEndpoint="wss://localhost/graphql"
/>

如果你使用apollo-server,端点URL应该从subscriptionsPath派生,但也可以直接在配置中设置:

const server = new ApolloServer({
  typeDefs,
  resolvers,
  playground: {
    subscriptionEndpoint: 'wss://localhost/graphql',
  },
});

编辑:

似乎没有办法使用特定订阅 URL 配置桌面客户端,除非您将它与包含 .graphqlconfig 的本地存储库一起使用。在这种情况下,您可以在配置文件中提供有关您的环境的其他信息,包括订阅 url,如 here 所述。

【讨论】:

  • 在graphql-playground(桌面客户端)
猜你喜欢
  • 2019-12-11
  • 2020-12-17
  • 2019-02-16
  • 2023-04-03
  • 2022-08-07
  • 2020-02-05
  • 2018-08-24
  • 2022-10-12
  • 2018-06-01
相关资源
最近更新 更多