Listen for Data Changes in Real-time with a GraphQL Subscription

InstructorEve Porcello

Share this video with your friends

Send Tweet

A GraphQL API can push new data to the client with the Subscription Type. In this lesson, we’ll listen to checkIn and checkOut mutations in real time.

To follow along with these queries, go to the Pet Library GraphQL Playground.

Sébastien BARRE
~ 5 years ago

Having some issues here with the subscription: could not connect to websocket endpoint wss://funded-pet-library.moonhighway.com/.

Eve Porcelloinstructor
~ 5 years ago

Looks like the default connections over a websocket with Apollo Server is 10 unless you specify more. I updated the code so that this wouldn't be a problem even if many people are connected. Thanks for the heads up!

Joël
~ 5 years ago

Hi @Eve, here Subscriptions are not testable "message": "Cannot read property 'headers' of undefined"

Eve Porcelloinstructor
~ 5 years ago

Make sure you are "logged in" and have your token present in the headers. That should resolve the problem! Thanks!

Vui General
~ 5 years ago

Hi, I am having an issue connecting to websocket from my browser. Getting following error:

{
  "error": "Could not connect to websocket endpoint wss://funded-pet-library.moonhighway.com/graphql. Please check if the endpoint url is correct."
}
Kofi Ocran
~ 5 years ago

@Vui I got the same error but went ahead to write the checkOut and checkIn mutations and I got the desired response for the subscription

Md mamunur Rashid
~ 4 years ago

Hello, Having some issues here with the subscription: { "error": "Could not connect to websocket endpoint wss://funded-pet-library.moonhighway.com/graphql. Please check if the endpoint url is correct." } /* Endpoint: https://funded-pet-library.moonhighway.com/

*/

~ 3 years ago

{ "error": "Could not connect to websocket endpoint wss://pet-library.moonhighway.com/graphql. Please check if the endpoint url is correct." }