macOS High Sierra Version 10.13.3
graphql-playground Version 1.4.5 (1.4.5.2716)
graphql-playground-middleware-express Version 1.5.7
A WebSocket connection to a provided subscription endpoint (ie ws://localhost:4000/subscriptions) should be established successfully.
Playground attempts to establish a WebSocket connection to a different endpoint than the one provided (perhaps a default / fallback endpoint) and fails.

As you can see in the screenshot above, a WebSocket connection is trying to be established to ws://localhost:4000/graphql, but that's not the endpoint I specified.
Clone relevant tutorial code from Apollo blog post (https://dev-blog.apollodata.com/tutorial-graphql-subscriptions-server-side-e51c32dc2951):
git clone https://github.com/apollographql/graphql-tutorial.git
cd graphql-tutorial
git checkout t6-end
cd server && npm install
npm install graphql-playground-middleware-express
Add the following code to server.js:
server.use(
'/playground',
expressPlayground({
endpoint: '/graphql',
subscriptionsEndpoint: 'ws://localhost:4000/subscriptions',
}),
);
Don't forget to import:
import expressPlayground from 'graphql-playground-middleware-express';
Start the server:
npm start
Go to http://localhost:4000/playground and check the console.
I have exactly the same problem, also related to https://github.com/graphcool/graphql-playground/issues/462.
I tried to debug into this by running the development commands mentioned in the README.md. Unfortunately, a Javaascript error occured (GraphQLPlayground not defined or something like that)
any plans to fix this?
In my case
I'm using apollo-server-express 2.0.0
I add config
playground: {
subscriptionEndpoint: `ws://${IP_Address}:${PORT}`
}
to ApolloServer.
it's working properly
It should work in the latest version, if its still problem please reopen.
Most helpful comment
In my case
I'm using apollo-server-express 2.0.0
I add config
to ApolloServer.
it's working properly