File tree Expand file tree Collapse file tree
main/java/graphql/schema/validation
test/groovy/graphql/schema/validation Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -189,7 +189,7 @@ private SchemaValidationError error(String msg) {
189189 boolean isCompatible (GraphQLOutputType constraintType , GraphQLOutputType objectType ) {
190190 if (isSameType (constraintType , objectType )) {
191191 return true ;
192- } else if (constraintType instanceof GraphQLUnionType ) {
192+ } else if (constraintType instanceof GraphQLUnionType && objectType instanceof GraphQLObjectType ) {
193193 return objectIsMemberOfUnion ((GraphQLUnionType ) constraintType , objectType );
194194 } else if (constraintType instanceof GraphQLInterfaceType && objectType instanceof GraphQLObjectType ) {
195195 return objectImplementsInterface ((GraphQLInterfaceType ) constraintType , (GraphQLObjectType ) objectType );
Original file line number Diff line number Diff line change 11package graphql.schema.validation
22
3+ import graphql.TestUtil
34import graphql.schema.GraphQLInterfaceType
45import graphql.schema.GraphQLObjectType
56import spock.lang.Specification
@@ -311,6 +312,29 @@ class TypesImplementInterfacesTest extends Specification {
311312 ! badErrorCollector. getErrors(). isEmpty()
312313 }
313314
315+ def " non-null union field implements nullable union interface field" () {
316+ when :
317+ TestUtil . schema('''
318+ schema { query: B }
319+
320+ union U = A
321+
322+ interface I {
323+ i: U
324+ }
325+
326+ type A {
327+ a: String
328+ }
329+
330+ type B implements I {
331+ i: U!
332+ }
333+ ''' )
334+
335+ then :
336+ noExceptionThrown()
337+ }
314338
315339 def " field is a non null object" () {
316340 given :
You can’t perform that action at this time.
0 commit comments