incremental delivery with deduplication + concurrent execution
At a glance
- Identifier: #1026
- Stage: RFCX: Closed 2023-07-12T20:53:51Z
- Champion: @yaacovCR
- PR: incremental delivery with deduplication + concurrent execution
Timeline
- Added to 2023-06-01 WG agenda
- Mentioned in 2023-06 WG notes
- Spec PR created on 2023-05-21 by yaacovCR
- Commit pushed: incremental delivery with deduplication and concurrent delivery on 2023-05-21 by @yaacovCR
- Commit pushed: CollectFields does not require path or asyncRecord (#11) on 2023-01-16 by @yaacovCR
- Commit pushed: replace server with service on 2023-01-15 by @robrichard
- Commit pushed: fix typo on 2022-12-05 by @robrichard
- Commit pushed: fix parentRecord argument in ExecuteStreamField (#7) on 2022-11-29 by @yaacovCR
- Commit pushed: clarify label is not required on 2022-11-23 by @robrichard
- 2 commits pushed on 2022-11-22:
- Commit pushed: Add error handling for stream iterators (#5) on 2022-11-21 by @yaacovCR
- Commit pushed: fix typos (#6) on 2022-11-18 by @yaacovCR
- Commit pushed: remove ResolveFIeldGenerator (#4) on 2022-11-16 by @yaacovCR
- Commit pushed: small fixes (#3) on 2022-11-07 by @yaacovCR
- Commit pushed: update on hasNext on 2022-11-01 by @robrichard
- Commit pushed: link to note on should on 2022-10-12 by @robrichard
- 3 commits pushed on 2022-09-09:
- 11 commits pushed on 2022-09-08:
- Add error boundary behavior by @robrichard
- defer/stream response => payload by @robrichard
- event stream => response stream by @robrichard
- link to path section by @robrichard
- use case no dash by @robrichard
- remove "or null" by @robrichard
- add detailed incremental example by @robrichard
- update label validation rule by @robrichard
- clarify hasNext on incremental example by @robrichard
- clarify canceling of subsequent payloads by @robrichard
- Add examples for non-null cases by @robrichard
- Commit pushed: clarify null behavior of if on 2022-08-24 by @robrichard
- 2 commits pushed on 2022-08-23:
- 7 commits pushed on 2022-08-18:
- Introduce @defer and @stream. by @robrichard
- Raise a field error if initialCount is less than zero by @robrichard
- wait for parent async record to ensure correct order of payloads by @robrichard
- spec updates to reflect latest discussions by @robrichard
- Note about mutation execution order by @robrichard
- minor change for uniqueness by @robrichard
- fix typos by @robrichard
- Commit pushed: Align deferred fragment field collection with reference implementation on 2022-08-03 by @robrichard
- 3 commits pushed on 2022-06-09:
- 2 commits pushed on 2022-03-23:
- Commit pushed: Clarification on labels on 2022-03-08 by @robrichard
- Commit pushed: add validation “Defer And Stream Directive Labels Are Unique” on 2022-03-07 by @robrichard
- 2 commits pushed on 2022-02-07:
- Commit pushed: deferDirective and visitedFragments on 2022-02-02 by @robrichard
- Commit pushed: fix typo on 2022-01-21 by @robrichard
- Commit pushed: add isCompletedIterator to AsyncPayloadRecord to track completed iter… on 2021-12-30 by @robrichard
- 2 commits pushed on 2021-12-20:
- 2 commits pushed on 2021-12-06:
- Commit pushed: fix typo on 2021-11-26 by @robrichard
- Commit pushed: allow extensions only subsequent payloads on 2021-11-25 by @robrichard
- Commit pushed: clarify negative values of initialCount on 2021-11-20 by @robrichard
- Commit pushed: clarification on defer/stream requirement on 2021-11-19 by @robrichard
- Commit pushed: Update Section 3 -- Type System.md on 2021-05-15 by @robrichard
- 3 commits pushed on 2021-02-17:
These spec edits should correspond to the working implementation of incremental delivery with deduplication currently posted as PR stack: https://github.com/graphql/graphql-js/pull/3894 => introduces Publisher https://github.com/graphql/graphql-js/pull/3886 => bulk of effort, introduces deduplication https://github.com/graphql/graphql-js/pull/3897 => adds pending
These spec edits do not currently include optional follow-on: https://github.com/graphql/graphql-js/pull/3895 => payload consolidation
[The diff to main might be helpful, but this is built on top of the amazing #742 and so the diff from that branch could be more useful.]
IMPORTANT NOTE:
These are hopefully trending toward complete in terms of the algorithm -- more explanatory prose should definitely be added.
TLDR?
The implementation and spec changes show how one can start executing deferred fragments semi-immediately (i.e. after deferring in an implementation-specific way), rather than waiting for the entire initial result to be emitted. This is not required -- one could still be compliant with the spec by deferring all the way until the initial result completes! In fact, how one defers is not per se observable and so the spec cannot mandate much about it with great normative force. But -- and I think this is important -- this PR and the implementation PR provide an algorithm/implementation/spec changes that give servers the flexibility to do what they think is right in that regard, and that might be desirable.
As of this moment, I am fairly confident in the implementation PR over at
graphql-js
, and the spec PR should generally correspond, demonstrating:= the
Field Group
andDefer Usage
record types that contain the information derived from the operation during field collection= the introduction of a distinction between
Incremental Data
records andSubsequent Result
records.Deferred Fragment
records andStream Items
records exemplifySubsequent Result
s that are sent as a group to the client. But an individualDeferred Fragment
Record may consist of a number of distinctDeferred Grouped Field Set
records, which may overlap with otherDeferred Fragment
Records and should not be sent more than once.Deferred Grouped Field Set
records are therefore a unit ofIncremental Data
and are tracked with a new record type.Stream Items
records always contain a single unit of incremental data that is sent only once with little complication; they therefore represent bothSubsequent Result
andIncremental Data
Records.= the new
Publisher
construct, with a set of algorithms that create and manipulate Subsequent Result and Incremental Data records.Mutation
of these records is not performed directly during execution, but only via interaction with the Publisher.= the deferMap, which maps
Defer Usage
records to individualDeferred Fragment
Subsequent Result
records** huge thanks to @urigo and @dotansimha of the guild for sponsoring my open-source work on this. **