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

Eve Porcello
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
Sébastien BARRE
~ 2 years ago

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

Eve Porcello
Eve Porcelloinstructor
~ 2 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
Joël
~ 2 years ago

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

Eve Porcello
Eve Porcelloinstructor
~ 2 years ago

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

Vui General
Vui General
~ a year 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
Kofi Ocran
~ a year 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
Md mamunur Rashid
~ 4 months 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/

*/