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.
Previous
What is the @client directive in Apollo Client?
Next
How do you implement field-level caching with cache hints in GraphQL?
More GraphQL Questions
View all →- Intermediate How do you implement pagination in GraphQL?
- Intermediate What is the Relay specification in GraphQL?
- Intermediate How do you implement authorization in GraphQL resolvers?
- Intermediate What is graphql-shield and how does it work?
- Intermediate How do you implement real-time subscriptions with GraphQL?