Recall & Review
beginner
What is a GraphQL subscription?
A GraphQL subscription is a way to get real-time updates from the server. It keeps a connection open and sends data when something changes.
Click to reveal answer
beginner
Basic syntax to start a subscription in GraphQL?
Use the
subscription keyword followed by the subscription name and the fields you want to receive updates for.Click to reveal answer
intermediate
How do you specify which events to listen to in a subscription?
Inside the subscription, you specify the event or data field you want updates for, similar to a query but it listens continuously.
Click to reveal answer
beginner
Example of a simple subscription for new messages?
subscription { newMessage { id content sender } } This listens for new messages and returns their id, content, and sender.
Click to reveal answer
intermediate
Why use subscriptions instead of queries for real-time data?
Queries fetch data once. Subscriptions keep the connection open and send updates automatically when data changes, saving time and resources.
Click to reveal answer
Which keyword starts a GraphQL subscription?
✗ Incorrect
The
subscription keyword is used to start a subscription operation in GraphQL.What does a subscription do?
✗ Incorrect
Subscriptions keep the connection open and send data updates in real-time.
Which of these is a valid subscription field selection?
✗ Incorrect
Subscriptions use the
subscription keyword and specify fields to receive updates.Subscriptions are best used for:
✗ Incorrect
Subscriptions provide real-time updates by keeping the connection open.
Which statement is true about GraphQL subscriptions?
✗ Incorrect
Subscriptions listen for events and send data continuously as changes happen.
Explain how to write a basic GraphQL subscription and what it does.
Think about how subscriptions differ from queries.
You got /3 concepts.
Describe why and when you would use a subscription instead of a query in GraphQL.
Consider the difference between one-time fetch and live updates.
You got /3 concepts.