Hive Router v0.3.23 supports @defer. Mark the slow part of an operation with it,
and the client gets the rest of the response first, without waiting for the slowest subgraph.
The router sends name and price as soon as they’re in. reviews follows in its own part once
the reviews subgraph answers. With several @defers, a fast fragment doesn’t wait for a slow one.
It’s off by default:
How it works
- Real deferred fetches. Deferred fields get subgraph fetches of their own, which start as soon
as their inputs are in and never hold back the primary part. That also works for fields of a
subgraph the primary part already calls, when the fragment is on an entity: the router goes back
to that subgraph through the type’s
@key. - Every transport. Responses go out over
multipart/mixed, SSE or WebSockets, in theincrementalSpec=v0.2format (pending,incremental,completed). Clients that ask formultipart/mixed;deferSpec=20220824, like Apollo Client 3, get the older format. @defer(if:)is planned once for both values.if: falsegives a regular response.- Safe nulls. A
nullfrom a deferred fragment can’t take away data another part already delivered. If it would, the fragment fails on its own, with its errors and no data. - Limits.
limits.max_deferscaps the@defers in one operation (4 by default), andtraffic_shaping.router.request_timeoutcovers every part.
Plugins, authorization, usage reporting, metrics, tracing and demand control all work with deferred responses.