Skip to content

Incremental Delivery spec draft - #1110

Open
robrichard wants to merge 6 commits into
graphql:mainfrom
robrichard:robrichard/defer-stream-v2
Open

robrichard wants to merge 6 commits into
graphql:mainfrom
robrichard:robrichard/defer-stream-v2

Conversation

@robrichard

Copy link
Copy Markdown
Contributor

Spec draft of @defer based on the response format in graphql/defer-stream-wg#69, with no duplication of fields. @stream will be added soon.

Please keep discussion limited to specifics on how the spec text is written. There is a dedicated discussion forum for questions, feedback, and comments on defer & stream: https://github.com/graphql/defer-stream-wg/discussions

@netlify

netlify Bot commented Sep 18, 2024 •

Copy link
Copy Markdown

✅ Deploy Preview for graphql-spec-draft ready!

Name Link
🔨 Latest commit 045e193
🔍 Latest deploy log https://app.netlify.com/projects/graphql-spec-draft/deploys/6a84c58b060764000769017d
😎 Deploy Preview https://deploy-preview-1110--graphql-spec-draft.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@owen-zora

Copy link
Copy Markdown

Hi @robrichard , do you have any expected timeline for this feature? We are really excited to have this feature for our product!

Comment thread spec/Section 6 -- Execution.md Resolved
@benjie

benjie commented Jun 12, 2025

Copy link
Copy Markdown
Member

The previous spec edits reached RFC2, should this also be RFC2?

Comment thread spec/Section 7 -- Response.md Resolved

- If {serial} is not provided, initialize it to {false}.
- Let {groupedFieldSet} and {newDeferUsages} be the result of
{CollectFields(objectType, selectionSet, variableValues)}.

@michaelstaib michaelstaib Feb 2, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new CollectFields requires a deferUsage argument ... this should be null for the initial call to CollectFields.

Suggested change
{CollectFields(objectType, selectionSet, variableValues)}.
{CollectFields(objectType, selectionSet, null, variableValues)}.

Also in this case its not clear while reading what null actually is for so maybe it should be declared first?

@leebyron leebyron added 📄 Draft (RFC 2) RFC Stage 2 (See CONTRIBUTING.md) and removed 💡 Proposal (RFC 1) RFC Stage 1 (See CONTRIBUTING.md) labels Mar 5, 2026
@leebyron

leebyron commented Mar 5, 2026

Copy link
Copy Markdown
Collaborator

Moving this to RFC2, draft.

More work to do for sure, but we're waaaaay closer to the end than the start and I believe we've fully understood the problem domain and are narrowing in on details now.

Massive props and excellent work to @robrichard for his continued championship and work on this RFC

robrichard and others added 2 commits August 18, 2026 16:49
Co-authored-by: Yaacov Rydzinski <yaacovCR@gmail.com>
Co-authored-by: Yaacov Rydzinski <yaacovCR@gmail.com>
@duckki

duckki commented Sep 19, 2026

Copy link
Copy Markdown

👋 I noticed a few minor corrections to make:

  1. In Section 6, Executing Fields, this line appears to be a typo:

    Append {fieldName} to {path}.

    It should append the response name—an alias when present, otherwise the field name—because response paths use response names.

  2. In Section 7, Incremental Stream Update Result, the final sentence appears to repeat true:

    The value of {"hasNext"} must be {true} for all but the last response in the incremental stream. Otherwise, {"hasNext"} must be {true}.

    The second value should be {false}. The wording could also be simplified to: “The value of {"hasNext"} must be {true} for every response except the last; it must be {false} for the last response.”

  3. In Section 6, Yielding Incremental Stream Results calls GetPendingEntry before Mapping Work Events to Response Events, yet the latter initializes idMap and nextID. Since GetPendingEntry already calls EnsureID, the ID state should instead be initialized in YieldIncrementalResults, before its initial GetPendingEntry call.

@duckki

duckki commented Sep 20, 2026

Copy link
Copy Markdown

For @defer(label: null) or @stream(label: null), should pending include "label": null, or omit label?

Both directives declare a nullable label: String. The validation rule says:

If {label} does not exist or is {null}:

  • Continue to the next {directive}.

I read that as exempting null from the uniqueness check, while still allowing the argument.

In GetPendingEntry, the algorithm takes the group or stream’s {label} and constructs a pending entry containing it. The response section says that if the directive “contains a label argument,” the pending notice “must contain an entry {"label"} with the value of this argument.” Together, these suggest that label: null produces "label": null in the pending notice.

Currently, GraphQL.js instead omits the entry and tests for that behavior.
Should this behavior be documented in the spec, or GraphQL.js needs to be changed?

- Increment {nextID} by {1}.
- Return {id}.

GetPendingEntry(newGroups, newStreams):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method returns a list of pending entries, though its name "GetPendingEntry" would suggest that it returns just a single entry.

This might be clearer if named "GetPendingEntries".

Comment on lines +1199 to +1205
EnsureID(node):

- If {idMap} has an entry for {node}, return that entry.
- Let {id} be {nextID} converted to a string.
- Set the entry for {node} in {idMap} to {id}.
- Increment {nextID} by {1}.
- Return {id}.

@jbellenger jbellenger Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My understanding is that these ids are expected to be opaque and should not be interpreted by clients. For example, clients should not parse id strings to an integer and compare them to determine if they are missing any delivery groups. The true requirement is that an id is a string value that is unique per node.

As written, though, this specific counter-based algorithm is normative.

Is it feasible to rework EnsureID to only specify the identity guarantees, with the counter-based impl described in a non-normative note?

I naively tried reworking it in the suggested edit.

Suggested change
EnsureID(node):
- If {idMap} has an entry for {node}, return that entry.
- Let {id} be {nextID} converted to a string.
- Set the entry for {node} in {idMap} to {id}.
- Increment {nextID} by {1}.
- Return {id}.
EnsureID(node):
- If {idMap} has an entry for {node}, return that entry.
- Let {id} be a string value that has not previously been assigned to any node in this incremental response.
- Set the entry for {node} in {idMap} to {id}.
- Return {id}.
Note: One implementation strategy is to maintain a counter initialized to zero for each incremental response. When assigning a new ID, convert the counter to a string and increment it by one.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that their exact values need not be prescribed, while these are public wire IDs used to correlate pending/completion notices and results. Implementations should be free to choose any string values, provided they remain stable for each node and unique across the incremental response. The counter-based algorithm would work well as a non-normative example.

@duckki

duckki commented Oct 17, 2026 •

Copy link
Copy Markdown

Could we clarify error reporting when an incremental delivery group fails?

Previously collected errors handled at nullable fields may reasonably be omitted from a failed completion. However, the completion can still have multiple propagating failure causes. For example, GraphQL.js #4870 reports multiple cached task rejections when several shared tasks have failed before a deferred group starts.

The draft’s GROUP_FAILURE mapping currently constructs [error]. Should it instead accept a non-empty list of errors explaining why the group cannot deliver its result? If multiple such failures are already available, should reporting all of them be required, or should selecting one remain permitted?

To support multiple causes, the mapping could become:

@@ GROUP_FAILURE
- Let {group} and {error} be the corresponding entries on {event}.
- Let {groupErrors} be a list containing {error}.
- Append {GetCompletedEntry(group, groupErrors)} to {completed}.
+ Let {group} and {errors} be the corresponding entries on {event}.
+ Assert: {errors} is a non-empty list of execution errors
+   whose propagation caused delivery of the group to fail.
+ Append {GetCompletedEntry(group, errors)} to {completed}.

This would allow multiple propagating causes while permitting omission of errors handled at nullable positions.

I’m leaving STREAM_FAILURE outside this question, since the motivating case concerns multiple shared task failures affecting one deferred group.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

📄 Draft (RFC 2) RFC Stage 2 (See CONTRIBUTING.md)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants