Recall & Review
beginner
What does unsubscribing mean in GraphQL subscriptions?
Unsubscribing means stopping the live updates from a GraphQL subscription. It tells the server you no longer want to receive data changes.
Click to reveal answer
beginner
How do you unsubscribe from a GraphQL subscription in client code?
You call the
unsubscribe() method on the subscription object returned when you start the subscription.Click to reveal answer
intermediate
Why is unsubscribing important in GraphQL subscriptions?
Unsubscribing frees up resources on both client and server. It stops unnecessary data flow and saves bandwidth and memory.
Click to reveal answer
intermediate
What happens if you don't unsubscribe from a GraphQL subscription?
The subscription stays active, and the client keeps receiving updates. This can cause wasted resources and slow performance.
Click to reveal answer
beginner
Show a simple example of unsubscribing from a GraphQL subscription using JavaScript.
const subscription = client.subscribe({ query: MY_SUBSCRIPTION }).subscribe({
next(data) { console.log(data); },
error(err) { console.error(err); }
});
// Later when you want to stop:
subscription.unsubscribe();Click to reveal answer
What method do you call to stop receiving updates from a GraphQL subscription?
✗ Incorrect
The correct method to stop a subscription is unsubscribe().
Why should you unsubscribe from a GraphQL subscription when no longer needed?
✗ Incorrect
Unsubscribing saves resources by stopping unnecessary data updates.
If you forget to unsubscribe, what is a likely consequence?
✗ Incorrect
Without unsubscribing, updates continue and resources are wasted.
In JavaScript, what does the subscribe() method return?
✗ Incorrect
subscribe() returns an object that has an unsubscribe() method to stop updates.
Which of these is NOT a reason to unsubscribe?
✗ Incorrect
Unsubscribing stops data flow, so keeping data means not unsubscribing.
Explain what unsubscribing means in GraphQL subscriptions and why it is important.
Think about stopping live updates and saving resources.
You got /3 concepts.
Describe how you unsubscribe from a GraphQL subscription in client code with an example.
Focus on the object returned by subscribe() and its method.
You got /3 concepts.