-
Notifications
You must be signed in to change notification settings - Fork 473
Description
Summary
@defer queries are absolute game changer allowing quick partial UI rendering and simple developer experience. However, currently @defer queries can only be meaningfully used on the client side. Apollo implements a method to "await" when the query with @defer statements is executed on the server side. While this allows to reuse a single query in both server and client side, it is a suboptimal solution since the whole goal of @defer is to be able to render your data incrementally as it comes.
Proposed Solution
What would be great if when executing a query containing @defer fields on the server side the non deferred fields are queried on the server side as expected, while @defer fields should not block the the server and querying propagates to the client side. As the deferred data is incrementally fetched on the client side, it gets merged and becomes available for the components.
Advantages
- Single query definition that can be reused on the server/client side
- Developer does not need to split the query into two "server query" and "client query with deferred fields"
- More compact and simple code
As far as I know no libraries support such hybrid approach yet, but it would be incredibly useful.