GraphQL subscriptions: a third operation type (alongside query and mutation) that establishes a persistent connection (typically WebSocket). The server pushes updates to subscribing clients when the specified data changes.
2 / 5
What transport layer typically powers GraphQL subscriptions?
WebSocket transport: subscriptions need a persistent, full-duplex channel. WebSocket over the graphql-ws protocol is the current standard, replacing the legacy subscriptions-transport-ws.
3 / 5
What is a subscription resolver responsible for?
Subscription resolver: has an async iterator (subscribe function) that yields events from a pub/sub system, and a resolve function that shapes each event into the GraphQL response. The client receives shaped data, not raw events.
4 / 5
Why must subscription servers handle connection management carefully?
Connection management: long-lived WebSocket connections consume file descriptors and memory. Servers must handle heartbeats (ping/pong), idle disconnection, graceful cleanup on client disconnect, and limits on concurrent connections per client.
5 / 5
How does filtering at the subscription resolver level improve scalability?
Subscription filtering: if 10,000 clients subscribe to order updates, broadcasting every order change to all would be wasteful. The resolver filters so each client only gets events matching their subscribed IDs, keeping data transfer minimal.