Skip to content

Replace ExecuteSelectionSet with ExecuteCollectedFields - #1039

Merged
leebyron merged 25 commits into
mainfrom
benjie/incremental-common
Jul 1, 2025
Merged

Replace ExecuteSelectionSet with ExecuteCollectedFields#1039
leebyron merged 25 commits into
mainfrom
benjie/incremental-common

Conversation

@benjie

@benjie benjie commented Aug 21, 2023

Copy link
Copy Markdown
Member

Essentially this PR replaces the ExecuteSelectionSet method with ExecuteCollectedFields (which essentially just drops the first line of ExecuteSelectionSet, which was responsible for collecting fields to be executed). It then refactors the rest of the spec to accommodate this change, reducing the repetition in ExecuteQuery, ExecuteMutation and ExecuteSubscriptionEvent; and removing MergeSelectionSets (which generated a "virtual" selection set to accomodate the ExecuteSelectionSet method), instead adding a CollectSubfields algorithm which produces a grouped field set directly, ready for execution.

I extracted this common refactoring from a number of my attempts to write spec changes for the @defer and @stream directives - it turns out that this refactoring of the spec was always needed as a base for my changes. Similarly, @yaacovCR found similar in his attempts to address this same problem, and raised #999 extracted from his solution. This PR was introduced independently of #999 (other than using the CollectSubfields algorithm name) however there is significant alignment, so @yaacovCR suggested that I raise it as an alternative PR.

It may be easier to review this PR in "split" view rather than "unified" view.

@netlify

netlify Bot commented Aug 21, 2023

Copy link
Copy Markdown

Deploy Preview for graphql-spec-draft ready!

Name Link
🔨 Latest commit cc17846
🔍 Latest deploy log https://app.netlify.com/projects/graphql-spec-draft/deploys/6864110092521d0008b6f11e
😎 Deploy Preview https://deploy-preview-1039--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.

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

benjie commented Feb 5, 2024

Copy link
Copy Markdown
Member Author

(Rebased on main)

@benjie
benjie force-pushed the benjie/incremental-common branch from b342b58 to a52310e Compare September 19, 2024 11:51
@benjie

benjie commented Sep 19, 2024

Copy link
Copy Markdown
Member Author

(Rebased on main)

@yaacovCR

This comment was marked as resolved.

@benjie

This comment was marked as resolved.

@yaacovCR

This comment was marked as resolved.

@Keweiqu

Keweiqu commented Oct 3, 2024

Copy link
Copy Markdown
Contributor

@benjie we need to formally define "grouped field set" in Section 2 "Language". You might have done so in a prior PR that I missed. Here is the link to us defining "section sets" in section 2 https://spec.graphql.org/draft/#sec-Selection-Sets

JoviDeCroock added a commit to JoviDeCroock/graphql-spec that referenced this pull request Feb 15, 2025
@benjie
benjie force-pushed the benjie/incremental-common branch from 6e76340 to 3c6dfb3 Compare April 25, 2025 09:01
Comment thread spec/Section 6 -- Execution.md Outdated
Comment on lines +398 to +404
:: A _field set_ is a list of selected fields that share the same _response
name_ (the field alias if defined, otherwise the field's name).

Note: The order of field selections in a _field set_ is significant, hence the
algorithms in this specification model it as a list. Any later duplicated field
selections in a field set will not impact its interpretation, so using an
ordered set would yield equivalent results.

@benjie benjie May 1, 2025

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Comment thread spec/Section 3 -- Type System.md Outdated
```

Valid operations must supply a nested field set for any field that returns an
Valid operations must supply a selection of fields for any field that returns an

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.

Not directly related to this PR but a more precise wording would be to use selectionSet here as fragments are also valid, not only fields.

Suggested change
Valid operations must supply a selection of fields for any field that returns an
Valid operations must supply a valid sub _selection set_ for any field that returns an

@leebyron
leebyron force-pushed the benjie/incremental-common branch from 1e42cc4 to d0fb75c Compare June 30, 2025 23:47
@leebyron
leebyron force-pushed the benjie/incremental-common branch from ed11e66 to 9c4a529 Compare July 1, 2025 00:19
@leebyron

leebyron commented Jul 1, 2025

Copy link
Copy Markdown
Collaborator

@benjie I made some substantial editorial changes here, especially to one of the term names. Please review!

@leebyron
leebyron force-pushed the benjie/incremental-common branch from e4a5199 to c776fa7 Compare July 1, 2025 01:18
@leebyron
leebyron force-pushed the benjie/incremental-common branch from c776fa7 to 97d43ba Compare July 1, 2025 03:16
@leebyron
leebyron merged commit 17e2a47 into main Jul 1, 2025
9 checks passed
@leebyron
leebyron deleted the benjie/incremental-common branch July 1, 2025 16:54
@github-project-automation github-project-automation Bot moved this from In Progress to Done in Benjie's GraphQL tasks Jul 1, 2025
@benjie

benjie commented Jul 2, 2025

Copy link
Copy Markdown
Member Author

Thanks Lee! Suggested edits raised in #1175

@benjie
benjie restored the benjie/incremental-common branch July 2, 2025 12:56
leebyron pushed a commit that referenced this pull request Jul 2, 2025
* Resolve ambiguity - we mean return type

For `type User { name: String }`, `User.name` is a field of an object
type (`User`). Clarify that we mean the return type of the field, not
the type to which it belongs.

* Consistency with collectedFieldsMap

* Reword to avoid 'During execution, ... before execution.'

* Serial execution relates to the set of fields, not each individual field

* Add missing close parenthesis

* Remove duplicate 'by', specific algorithm is detailed in next paragraph

* CollectFields() produces many _field set_

* Minor edits
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

✏️ Editorial PR is non-normative or does not influence implementation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants