0
0
GraphQLquery~5 mins

Subscription lifecycle in GraphQL - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is a subscription in GraphQL?
A subscription in GraphQL is a way to get real-time updates from the server. It keeps a connection open and sends data to the client whenever an event happens.
Click to reveal answer
beginner
What happens when a client starts a subscription?
When a client starts a subscription, it opens a persistent connection to the server, usually over WebSocket, to listen for specific events or data changes.
Click to reveal answer
intermediate
How does the server send data during a subscription?
The server sends data to the client whenever the subscribed event occurs. This data is sent as a stream of messages over the open connection.
Click to reveal answer
intermediate
What is the role of WebSocket in GraphQL subscriptions?
WebSocket provides a full-duplex communication channel that stays open, allowing the server to push updates to the client instantly during a subscription.
Click to reveal answer
beginner
How does a client stop a subscription?
A client stops a subscription by closing the connection or sending an unsubscribe message, which tells the server to stop sending updates.
Click to reveal answer
What does a GraphQL subscription do?
AProvides real-time updates from the server
BFetches data once like a query
CDeletes data on the server
DUpdates data on the client only
Which protocol is commonly used to keep a subscription connection open?
ASMTP
BFTP
CHTTP GET
DWebSocket
When does the server send data in a subscription?
AWhenever the subscribed event happens
BOnly when the client requests it
CAt fixed time intervals
DOnly once at the start
How does a client end a subscription?
ABy sending a query
BBy refreshing the page
CBy closing the connection or unsubscribing
DBy sending a mutation
What is the main benefit of using subscriptions?
AFaster database writes
BReal-time data updates without polling
CSimpler queries
DBetter security
Explain the lifecycle of a GraphQL subscription from start to finish.
Think about how the connection starts, how data flows, and how it ends.
You got /5 concepts.
    Describe why WebSocket is important for GraphQL subscriptions.
    Consider how data moves between client and server continuously.
    You got /4 concepts.