Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deferred fragments should not change ordering of fields within initial response #1054

Draft
wants to merge 64 commits into
base: main
Choose a base branch
from

Conversation

yaacovCR
Copy link
Contributor

@yaacovCR yaacovCR commented Nov 9, 2023

builds on #1052 and so the diff from that should be useful:

yaacovCR/graphql-spec@deduplicate3...yaacovCR:graphql-spec:deduplicate4

Copy link

netlify bot commented Nov 9, 2023

Deploy Preview for graphql-spec-draft ready!

Name Link
🔨 Latest commit 9b274db
🔍 Latest deploy log https://app.netlify.com/sites/graphql-spec-draft/deploys/6569706ac045a40008d9b918
😎 Deploy Preview https://deploy-preview-1054--graphql-spec-draft.netlify.app/draft
📱 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 site configuration.

robrichard and others added 28 commits November 18, 2023 22:58
Update Section 3 -- Type System.md

Update Section 3 -- Type System.md

Update Section 3 -- Type System.md

Update Section 6 -- Execution.md

Update Section 6 -- Execution.md

Update Section 6 -- Execution.md

Update Section 6 -- Execution.md

Update Section 6 -- Execution.md

Update Section 6 -- Execution.md

Update Section 6 -- Execution.md

Update Section 6 -- Execution.md

Update Section 6 -- Execution.md

Amend changes

change initial_count to initialCount

add payload fields to Response section

add stream validation for overlapping fields

spelling updates

add note about re-execution

add note about final payloads

label is optional

fix build

Update ExecuteQuery with hasNext logic

fix spelling

fix spaces

Update execution to add defer/stream to mutations and subscriptions

clarify stream records

Apply suggestions from code review

Co-authored-by: Benjie Gillam <[email protected]>

missing bracket

Update spec/Section 7 -- Response.md

Co-authored-by: Benjie Gillam <[email protected]>

clarify line about stream record iterator

update visitedFragments with defer

Updates to consolidate subsequent payload logic for queries, mutations, and subscriptions

Apply suggestions from code review

Co-authored-by: Benjie Gillam <[email protected]>

address review feedback

Add handling of termination signal

more formatting

fix spelling

Add assertion for record type

add "Stream Directives Are Used On List Fields" validation rule

Add defaultValue to @stream initialCount

Update spec/Section 5 -- Validation.md

Co-authored-by: Benjie Gillam <[email protected]>

# Conflicts:
#	spec/Section 3 -- Type System.md
#	spec/Section 5 -- Validation.md
#	spec/Section 6 -- Execution.md
#	spec/Section 7 -- Response.md
# Conflicts:
#	spec/Section 6 -- Execution.md
# Conflicts:
#	spec/Section 3 -- Type System.md
# Conflicts:
#	spec/Section 3 -- Type System.md
# Conflicts:
#	spec/Section 3 -- Type System.md
# Conflicts:
#	spec/Section 7 -- Response.md
# Conflicts:
#	spec/Section 7 -- Response.md
# Conflicts:
#	spec/Section 3 -- Type System.md
#	spec/Section 6 -- Execution.md
# Conflicts:
#	spec/Section 7 -- Response.md
# Conflicts:
#	spec/Section 6 -- Execution.md
# Conflicts:
#	spec/Section 6 -- Execution.md
# Conflicts:
#	spec/Section 6 -- Execution.md
…ators

# Conflicts:
#	spec/Section 6 -- Execution.md
robrichard and others added 20 commits November 18, 2023 22:58
* add comma

* remove unused parameter
* streamline stream execution

Currently, these spec changes introduce a new internal function named `ResolveFieldGenerator` that is suggested parallels `ResolveFieldValue`. This function is used  during field execution such that if the stream directive is specified, it is called instead of `ResolveFieldValue`.

The reference implementation, however, does not require any such function, simply utilizing the result of `ResolveFieldValue`.

With incremental delivery, collections completed by `CompleteValue` should be explicitly iterated using a well-defined iterator, such that the iterator can be passed to `ExecuteStreamField`. But this does not require a new internal function to be specified/exposed.

Moreover, introducing this function causes a mixing of concerns between the `ExecuteField` and `CompleteValue` algorithms; Currently, if stream is specified for a field, `ExecuteField` extracts the iterator and passes it to `CompleteValue`, while if stream is not specified, the `ExecuteField` passes the collection, i.e. the iterable, not the iterator. In the stream case, this shunts some of the logic checking the validity of resolution results into field execution. In fact, it exposes a specification "bug" => in the stream case, no checking is actually done that `ResolveFieldGenerator` returns an iterator!

This change removes `ResolveFieldGenerator` and with it some complexity, and brings it in line with the reference implementation.

The reference implementation contains some simplification of the algorithm for the synchronous iterator case (we don't have to preserve the iterator on the StreamRecord, because there will be no early close required and we don't have to set isCompletedIterator, beacuse we don't have to create a dummy payload for termination of the asynchronous stream), We could consider also removing these bits as well, as they are an implementation detail in terms of how our dispatcher is managing its iterators, but that should be left for another change.

* run prettier
* fix whitespace

* complete renaming of initialItems
* Add error handling for stream iterators

* also add iterator error handling within CompleteValue

* incorporate feedback
Co-authored-by: Simon Gellis <[email protected]>
@yaacovCR
Copy link
Contributor Author

yaacovCR commented Dec 7, 2023

Requires rebasing with the changes to #1052 => and confirmation from the WG that this would be the desired behavior!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants