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

allow unions to declare implementation of interfaces #3527

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

yaacovCR
Copy link
Contributor

@yaacovCR yaacovCR commented Apr 5, 2022

@netlify
Copy link

netlify bot commented Apr 5, 2022

Deploy Preview for compassionate-pike-271cb3 ready!

Name Link
🔨 Latest commit 986b79a
🔍 Latest deploy log https://app.netlify.com/sites/compassionate-pike-271cb3/deploys/628c8cd58fe5d90008b8f580
😎 Deploy Preview https://deploy-preview-3527--compassionate-pike-271cb3.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 site settings.

@github-actions
Copy link

github-actions bot commented Apr 5, 2022

Hi @yaacovCR, I'm @github-actions bot happy to help you with this PR 👋

Supported commands

Please post this commands in separate comments and only one per comment:

  • @github-actions run-benchmark - Run benchmark comparing base and merge commits for this PR
  • @github-actions publish-pr-on-npm - Build package from this PR and publish it on NPM

yaacovCR added a commit to graphql/graphql-wg that referenced this pull request Apr 5, 2022
benjie added a commit to graphql/graphql-wg that referenced this pull request Apr 5, 2022
* add agenda item for unions implementing interfaces

   - Spec PR: graphql/graphql-spec#939
   - graphql-js PR (WIP): graphql/graphql-js#3527

* Update agendas/2022/2022-04-07.md

Co-authored-by: Benjie Gillam <benjie@jemjie.com>
@yaacovCR yaacovCR changed the title WIP: allow unions to declare implementation of interfaces allow unions to declare implementation of interfaces Apr 5, 2022
@yaacovCR yaacovCR marked this pull request as ready for review April 5, 2022 19:25
@yaacovCR yaacovCR added the spec RFC Implementation of a proposed change to the GraphQL specification label Apr 5, 2022
@yaacovCR
Copy link
Contributor Author

yaacovCR commented Apr 7, 2022

@yaacovCR
Copy link
Contributor Author

yaacovCR commented Apr 7, 2022

Should queries be allowed to select fields directly on the union now that the union definitely implements the field?

Some exploration within the reference implementation yielded that queries of this type would execute anyway without a problem, but fail validation because of the FieldsOnCorrectTypeRule.

So, this rule would possibly need to be updated for a union to find the field on one of the interfaces it implements!

yaacovCR added a commit to yaacovCR/graphql-executor that referenced this pull request Apr 29, 2022
Intersections of unions and interfaces can be considered to "implement" their unions and interface members.

A type with a field of type Intersection will satisfy an interface where the field defined in the interface is one of the member types of the intersection.

Alternative to graphql#3527
yaacovCR added a commit to yaacovCR/graphql-executor that referenced this pull request Apr 29, 2022
Intersections of unions and interfaces can be considered to "implement" their unions and interface members.

A type with a field of type Intersection will satisfy an interface where the field defined in the interface is one of the member types of the intersection.

Alternative to graphql#3527
yaacovCR added a commit to yaacovCR/graphql-executor that referenced this pull request Apr 29, 2022
Intersections of unions and interfaces can be considered to "implement" their unions and interface members.

A type with a field of type Intersection will satisfy an interface where the field defined in the interface is one of the member types of the intersection.

Alternative to graphql#3527
yaacovCR added a commit to yaacovCR/graphql-executor that referenced this pull request Apr 29, 2022
Intersections of unions and interfaces can be considered to "implement" their unions and interface members.

A type with a field of type Intersection will satisfy an interface where the field defined in the interface is one of the member types of the intersection.

Alternative to graphql#3527
yaacovCR added a commit to yaacovCR/graphql-executor that referenced this pull request Apr 29, 2022
Intersections of unions and interfaces can be considered to "implement" their unions and interface members.

A type with a field of type Intersection will satisfy an interface where the field defined in the interface is one of the member types of the intersection.

Alternative to graphql#3527
yaacovCR added a commit to yaacovCR/graphql-executor that referenced this pull request Apr 30, 2022
Intersections of unions and interfaces can be considered to "implement" their unions and interface members.

A type with a field of type Intersection will satisfy an interface where the field defined in the interface is one of the member types of the intersection.

Alternative to graphql#3527
yaacovCR added a commit to yaacovCR/graphql-executor that referenced this pull request May 3, 2022
Intersections of unions and interfaces can be considered to "implement" their unions and interface members.

A type with a field of type Intersection will satisfy an interface where the field defined in the interface is one of the member types of the intersection.

Alternative to graphql#3527
yaacovCR added a commit to yaacovCR/graphql-executor that referenced this pull request May 3, 2022
Intersections of unions and interfaces can be considered to "implement" their unions and interface members.

A type with a field of type Intersection will satisfy an interface where the field defined in the interface is one of the member types of the intersection.

Alternative to graphql#3527
yaacovCR added a commit to yaacovCR/graphql-executor that referenced this pull request May 3, 2022
Intersections of unions and interfaces can be considered to "implement" their unions and interface members.

A type with a field of type Intersection will satisfy an interface where the field defined in the interface is one of the member types of the intersection.

Alternative to graphql#3527
yaacovCR added a commit to yaacovCR/graphql-executor that referenced this pull request May 3, 2022
Intersections of unions and interfaces can be considered to "implement" their unions and interface members.

A type with a field of type Intersection will satisfy an interface where the field defined in the interface is one of the member types of the intersection.

Alternative to graphql#3527
yaacovCR added a commit to yaacovCR/graphql-executor that referenced this pull request May 3, 2022
Intersections of unions and interfaces can be considered to "implement" their unions and interface members.

A type with a field of type Intersection will satisfy an interface where the field defined in the interface is one of the member types of the intersection.

Alternative to graphql#3527
@yaacovCR yaacovCR force-pushed the union branch 4 times, most recently from 6f229f7 to ecd0e3c Compare May 23, 2022 21:18
@yaacovCR
Copy link
Contributor Author

Decision Record We decided at the last WG that if unions implement interfaces, then they have directly querable fields. This PR and the spec PR have been updated with the changes for introspection, validation.

Now all composite types have a getFields method!

WIP: more tests required

complete code coverage is already there, but goal is to have a test
where union implements an interface wherever there is a test for an
interface implementing interface
@yaacovCR
Copy link
Contributor Author

Actually, this naive field copying from the interfaces to the Union does not account for different interfaces with valid overlapping fields like new arguments with defaults. Work to do!

mattstern31 pushed a commit to mattstern31/graphql-wg-membership-note that referenced this pull request Dec 1, 2022
* add agenda item for unions implementing interfaces

   - Spec PR: graphql/graphql-spec#939
   - graphql-js PR (WIP): graphql/graphql-js#3527

* Update agendas/2022/2022-04-07.md

Co-authored-by: Benjie Gillam <benjie@jemjie.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
spec RFC Implementation of a proposed change to the GraphQL specification
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant