Skip to content

Commit

Permalink
fix(compiler): add failing test for spread of empty interface
Browse files Browse the repository at this point in the history
`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
  • Loading branch information
goto-bus-stop committed Aug 20, 2024
1 parent b510f48 commit 5d804c9
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
type Query {
intf: Intf
}
interface Intf {
nothing: Int
}

query SelectDirectly {
intf { nothing }
}

query UsingInlineFragment {
intf {
... on Intf { nothing }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
type Query {
intf: Intf
}

interface Intf {
nothing: Int
}

query SelectDirectly {
intf {
nothing
}
}

query UsingInlineFragment {
intf {
... on Intf {
nothing
}
}
}

0 comments on commit 5d804c9

Please sign in to comment.