skip to content

Transports & Subscriptions

Transport-agnostic on paper and almost always HTTP plus a socket in practice. Subscriptions are the part the specification leaves to the implementer, which is exactly why interviewers push on them.

part ofGraphQLoverview, primer and where to startread it →
on this pageshow

questions

page 2 of 2

Why does the graphql-ws subprotocol define its own ping and pong JSON messages?

level: middleimportance: nice to knowfreq 22%

basics

~20 s

Because a browser's WebSocket API gives page JavaScript no way to send or observe the transport's own liveness probe. The subprotocol therefore defines ping and pong as ordinary JSON messages that either side may send, carrying no operation id.

open as a page

When does splitting a GraphQL response with @defer actually improve what the user sees?

level: seniorimportance: nice to knowfreq 20%

basics

~20 s

Only when the deferred part is measurably slower than the rest and the interface can render usefully without it. If the client blocks on the whole tree, or the slow field is what the screen exists to show, deferring adds payloads and merge logic and moves nothing.

open as a page

Your GraphQL server switches every response to application/graphql-response+json. What breaks, and how does Accept let you stage it?

level: seniorimportance: nice to knowfreq 22%

basics

~20 s

Failures that used to answer 200 start answering 4xx, so client and infrastructure code keyed on the status takes a different branch. The GraphQL over HTTP draft makes the choice Accept-driven, so a server answers the newer type only to clients that asked.

open as a page

In a batched GraphQL request, why do per-operation caching and tracing stop working?

level: seniorimportance: nice to knowfreq 24%

basics

~20 s

Because the unit the infrastructure sees is the batch, not the operation. One composite POST body means one cache key, one status, one access-log line and one span, so hit rates, error rates and latency can no longer be attributed to individual operations.

open as a page

How do you budget capacity for a GraphQL subscription feature whose cost is events multiplied by subscribers?

level: principalimportance: nice to knowfreq 26%

basics

~20 s

Budget in executions per second, not sockets: peak subscribers on the hottest single entity times that entity's event rate, times the CPU and backend calls one execution costs. Then decide whether the feature can afford that.

open as a page

showing 31–35 of 35