代码之家  ›  专栏  ›  技术社区  ›  Jagadesha NH

如何更改graphql游乐场中的websocket url(订阅)

  •  1
  • Jagadesha NH  · 技术社区  · 7 年前

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

    默认情况下会ping

    wss://localhost/graphql
    

    我需要把它改成推送网址

    0 回复  |  直到 7 年前
        1
  •  6
  •   Daniel Rearden    7 年前

    如果运行的是GraphQL Playground的独立实例,则URL将作为道具直接传递给组件:

    <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

    推荐文章