Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change websocket url in graphql-playground (subscriptions)

I wanted to change the graphql websocket end point inside graphql, anyone know how to do this?

by default it pings

wss://localhost/graphql

I need to change it to pusher url

thanks :-)

like image 697
Jagadesha NH Avatar asked Jan 27 '23 14:01

Jagadesha NH


1 Answers

If you are running a standalone instance of GraphQL Playground, the URL is passed directly to the component as a prop:

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

If you're using apollo-server, the endpoint URL should be derived from the subscriptionsPath, but it can also be set directly in the config:

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

EDIT:

It doesn't appear there's a way to configure the desktop client with a specific subscription URL, unless you're using it with a local repo that contains a .graphqlconfig. In that case, you can provide additional information about your environment, including the subscription url, in the config file as outlined here.

like image 188
Daniel Rearden Avatar answered May 16 '23 10:05

Daniel Rearden