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

Adds field selection RFC #35

Merged
merged 17 commits into from
Sep 7, 2024

Conversation

PascalSenn
Copy link
Contributor

No description provided.

@smyrick
Copy link

smyrick commented May 2, 2024

From the meeting on May 2, @benjie has a comparable solution defined that builds on top of the schema coordinates proposal

In short, this pathing operator . is replaced with > and then selection is schema coordinates

https://github.com/graphql/graphql-wg/blob/main/rfcs/OperationExpressions.md

Copy link
Member

@benjie benjie left a comment

Choose a reason for hiding this comment

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

I've included some comments below, but I like the direction of the last solution.

To my mind the system knows if the input is a scalar or not. If it's a scalar, we expect a "single field" expression. If it's an input object, we expect a "multi field" expression (key1: expression1 key2: expression2); and for each of these expressions we apply the same heuristics: if it's a scalar, a single field expression, if an input object then a multi field expression wrapped in {} to avoid ambiguity.

My main concern is that the "expression" should use GraphQL syntax to explicitly select a single value. It's not terrible that this is implied via selection sets and the system knowing to traverse, but it would be better if this just "fell out" of the GraphQL syntax automatically, so I'm keen to see if exploring the flat chain syntax would get us any closer.

rfcs/field-selection.md Outdated Show resolved Hide resolved

```graphql
extend type Query {
mediaById(id: ID! @is(field: "<Movie>.id | <Book>.id")): MovieOrBook @lookup
Copy link
Member

Choose a reason for hiding this comment

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

With operation expressions this would be:

Suggested change
mediaById(id: ID! @is(field: "<Movie>.id | <Book>.id")): MovieOrBook @lookup
mediaById(id: ID! @is(field: "Movie.id Book.id")): MovieOrBook @lookup

That would effectively compile out to: ... Movie { id } ... Book { id }.

rfcs/field-selection.md Show resolved Hide resolved
rfcs/field-selection.md Outdated Show resolved Hide resolved
rfcs/field-selection.md Show resolved Hide resolved
rfcs/field-selection.md Outdated Show resolved Hide resolved
rfcs/field-selection.md Outdated Show resolved Hide resolved
rfcs/field-selection.md Outdated Show resolved Hide resolved
spec/Appendix A -- Field Selection.md Outdated Show resolved Hide resolved
spec/Appendix A -- Field Selection.md Outdated Show resolved Hide resolved
spec/Appendix A -- Field Selection.md Outdated Show resolved Hide resolved
spec/Appendix A -- Field Selection.md Outdated Show resolved Hide resolved
spec/Appendix A -- Field Selection.md Outdated Show resolved Hide resolved
spec/Appendix A -- Field Selection.md Outdated Show resolved Hide resolved
spec/Appendix A -- Field Selection.md Show resolved Hide resolved
spec/Appendix A -- Field Selection.md Outdated Show resolved Hide resolved
rfcs/field-selection.md Show resolved Hide resolved
@michaelstaib michaelstaib merged commit a82bee2 into graphql:main Sep 7, 2024
1 check passed
PascalSenn added a commit to PascalSenn/composite-schemas-spec that referenced this pull request Nov 7, 2024
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.

7 participants