Incremental Delivery🔗
Note that incremental delivery is currently experimental and may change in the future. The
@deferand@streamdirectives are not part of the GraphQL specification yet. They are an RFC in the GraphQL Working Group and the transport RFC they are delivered over is a draft as well.graphql-corealso still exposes incremental execution under an "experimental" name.
Undine has experimental support for incremental delivery of data
using the @defer and @stream directives. To enable incremental delivery,
all of the following must be true:
EXPERIMENTAL_INCREMENTAL_DELIVERYmust be set toTrue- Async support must be enabled
Let's look at an example of incremental delivery using the @defer and @stream directives.
Given the following schema:
If we wanted to query the "slow" field, the client would need to wait for five seconds for the server to resolve it before it can show any of the other data.
However, using the @defer directive, the client can receive the rest of the data immediately and
the deferred data when it's complete. The @defer directive works on fragment spreads and inline fragments.
Similarly, if we wanted to query the "countdown" field, the client would need to wait for ten seconds for the entire countdown to end before it can show any of the other data.
However, using the @stream directive, the client can receive the rest of the data immediately
and stream in each countdown result as they become available. The @stream directive works on list fields.