Challenge - 5 Problems
Subscription Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate2:00remaining
What happens when you unsubscribe from a GraphQL subscription?
In a GraphQL subscription, what is the expected behavior after a client unsubscribes?
Attempts:
2 left
💡 Hint
Think about what unsubscribing means in a real-life newsletter subscription.
✗ Incorrect
Unsubscribing means the client no longer wants to receive updates, so the server stops sending data.
❓ query_result
intermediate2:00remaining
Identify the output after unsubscribing
Given a GraphQL subscription that sends live chat messages, what will the client receive after unsubscribing?
GraphQL
subscription {
newMessage {
id
content
}
}
// Client unsubscribes after receiving 3 messagesAttempts:
2 left
💡 Hint
Unsubscribing stops the flow of new data.
✗ Incorrect
After unsubscribing, the client stops receiving any new messages.
📝 Syntax
advanced2:00remaining
Which code snippet correctly unsubscribes from a GraphQL subscription?
Select the code snippet that properly unsubscribes from a GraphQL subscription using JavaScript.
GraphQL
const subscription = client.subscribe({ query: NEW_MESSAGES }); // Unsubscribe code here
Attempts:
2 left
💡 Hint
Look for the method directly on the subscription object.
✗ Incorrect
The unsubscribe() method is called on the subscription object to stop receiving updates.
❓ optimization
advanced2:00remaining
Optimizing resource usage after unsubscribing
Why is it important for the server to clean up resources after a client unsubscribes from a GraphQL subscription?
Attempts:
2 left
💡 Hint
Think about what happens if unused subscriptions stay active.
✗ Incorrect
Cleaning up resources prevents the server from wasting memory and CPU on inactive subscriptions.
🔧 Debug
expert3:00remaining
Debugging why unsubscribing does not stop updates
A client unsubscribes from a GraphQL subscription but still receives updates. What is the most likely cause?
Attempts:
2 left
💡 Hint
Check how the client handles the subscription object.
✗ Incorrect
If unsubscribe() is not called properly, the server keeps sending updates.