⬡ GraphQL Intermediate

What is deferred query execution in GraphQL?

Answer

Deferred execution (via the @defer directive) allows a GraphQL query to return a response incrementally — sending the primary data first and deferring slower fields to stream later. Example: query { user(id: "1") { name ... @defer { slowExpensiveField { data } } } } — the user's name arrives immediately; the deferred section arrives later via a multipart HTTP stream. The transport uses multipart/mixed content type (similar to HTTP streaming). Benefits: faster initial render, better user experience for queries with mixed fast/slow fields, allows progressive rendering. Requires server support (Apollo Server 4+ with @defer plugin, Yoga) and client support (Apollo Client 3.7+). The @stream directive is related — it streams list items as they are resolved rather than waiting for the full list.