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

fix(compiler): fix validation for fragment spread of interface without implementers #896

Merged

Conversation

goto-bus-stop
Copy link
Member

@goto-bus-stop goto-bus-stop commented Aug 20, 2024

This Intf has no implementations. As written in the spec, doing a ... on Intf fragment spread should never work, as the set of possible types is empty and can never intersect with the parent type. However, implementations like graphql-js and graphql-go have an early check, accepting the fragment if the type condition is equal to the parent type. This tests reproduces that.

We may want to align with graphql-js and graphql-go rather than the spec here for compatibility? Though it's not something that's likely to happen in the real world.

Ref graphql/graphql-spec#1109

`Intf` has no implementations. As written in the spec, doing a `... on
Intf` fragment spread should never work, as the set of possible types is
empty and can never intersect with the parent type. However,
implementations like graphql-js and graphql-go have an early check,
accepting the fragment if the type condition is equal to the parent
type. This tests reproduces that.

We may want to align with graphql-js and graphql-go rather than the spec
here for compatibility? Though it's not something that's likely to
happen in the real world.

Ref graphql/graphql-spec#1109
@goto-bus-stop goto-bus-stop changed the title fix(compiler): add failing test for spread of empty interface fix(compiler): fix validation for fragment spread of interface without implementers Aug 20, 2024
Comment on lines +7 to 9
type Impl implements A & B {
name: String
}
Copy link
Member Author

Choose a reason for hiding this comment

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

Unrelated change, just fixing the schema so it doesn't rely on having an interface with 0 implementers

@duckki
Copy link

duckki commented Aug 20, 2024

I agree that Apollo's validator is spec-compliant currently, while others are not :)

At the same time, this could be an oversight in the spec. It's good to be able to test queries before writing an implementation (despite the weirdness of conditioning on the parent type).

@goto-bus-stop goto-bus-stop marked this pull request as ready for review August 23, 2024 08:22
@goto-bus-stop goto-bus-stop merged commit d93c1fc into main Aug 26, 2024
12 checks passed
@goto-bus-stop goto-bus-stop deleted the renee/validate-query-with-no-interface-implementers branch August 26, 2024 08:09
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.

3 participants