graphql-js icon indicating copy to clipboard operation
graphql-js copied to clipboard

allow unions to declare implementation of interfaces

Open yaacovCR opened this issue 2 years ago • 6 comments

See: https://github.com/graphql/graphql-spec/pull/939

yaacovCR avatar Apr 05 '22 10:04 yaacovCR

Deploy Preview for compassionate-pike-271cb3 ready!

Name Link
Latest commit 986b79a94a9053062325dd9ca5bbbb810e7854d5
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.

netlify[bot] avatar Apr 05 '22 10:04 netlify[bot]

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

github-actions[bot] avatar Apr 05 '22 10:04 github-actions[bot]

https://github.com/graphql/graphql-spec/pull/939#issuecomment-1092282972

yaacovCR avatar Apr 07 '22 23:04 yaacovCR

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 avatar Apr 07 '22 23:04 yaacovCR

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!

yaacovCR avatar May 23 '22 21:05 yaacovCR

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!

yaacovCR avatar May 24 '22 13:05 yaacovCR