You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Interface Using a Union Fails when Implemented #382
I have an interface that defines two properties. Both properties are defined with a type that is a union, this is done so that it can be implemented and overridden with a concrete type that is one of the union types defined in the schema. Here is a simplified version of the schema to illustrate this structure in GQL.
The exception is thrown in SchemaParser.kt on line 349. It fails the conditional that it is an acceptable output type. The property for unionDefinitions doesn't have the union in its list.
The unions you defined here don't actually seem to be doing a union though? So I'd expect something like union Result = Node | OtherNode. That might be why it's not added to the unionDefinitions. This seems to be a graphql-java-tools issue though, so I'll transfer this issue to that project.
I think we do not properly handle the case where a union only has a single type. I think we should just throw an error as it does not seem to be a valid grammar.
Closing as a duplicate of #597. Same root cause: a union referenced only from interface fields is never discovered by the scanner. Workaround until it is fixed: includeUnusedTypes(true) plus dictionary entries for the union members.
Activity
oliemansm commentedon Apr 4, 2020
The unions you defined here don't actually seem to be doing a union though? So I'd expect something like
union Result = Node | OtherNode. That might be why it's not added to theunionDefinitions. This seems to be a graphql-java-tools issue though, so I'll transfer this issue to that project.vojtapol commentedon Apr 16, 2020
I think we do not properly handle the case where a union only has a single type. I think we should just throw an error as it does not seem to be a valid grammar.
https://graphql.org/learn/schema/#union-types
lqc commentedon Mar 14, 2021
You are looking at an example, not the spec:
"A Union type must include one or more unique member types."
Having a union with a single type is useful because you can also extend unions.
oryan-block commentedon Oct 3, 2026
Closing as a duplicate of #597. Same root cause: a union referenced only from interface fields is never discovered by the scanner. Workaround until it is fixed:
includeUnusedTypes(true)plus dictionary entries for the union members.Discover unions and interfaces used only by interface fields