@@ -116,20 +116,23 @@ private SchemaValidationError error(String msg) {
116116 return new SchemaValidationError (ObjectDoesNotImplementItsInterfaces , msg );
117117 }
118118
119- boolean isCompatible (GraphQLOutputType a , GraphQLOutputType b ) {
120- if (isSameType (a , b )) {
119+ /**
120+ * @return {@code true} if the specified objectType satisfies the constraintType.
121+ */
122+ boolean isCompatible (GraphQLOutputType constraintType , GraphQLOutputType objectType ) {
123+ if (isSameType (constraintType , objectType )) {
121124 return true ;
122- } else if (a instanceof GraphQLUnionType ) {
123- return objectIsMemberOfUnion ((GraphQLUnionType ) a , b );
124- } else if (a instanceof GraphQLInterfaceType && b instanceof GraphQLObjectType ) {
125- return objectImplementsInterface ((GraphQLInterfaceType ) a , (GraphQLObjectType ) b );
126- } else if (a instanceof GraphQLList && b instanceof GraphQLList ) {
127- GraphQLOutputType wrappedA = (GraphQLOutputType ) ((GraphQLList ) a ).getWrappedType ();
128- GraphQLOutputType wrappedB = (GraphQLOutputType ) ((GraphQLList ) b ).getWrappedType ();
129- return isCompatible (wrappedA , wrappedB );
130- } else if (b instanceof GraphQLNonNull ) {
131- GraphQLOutputType wrappedB = (GraphQLOutputType ) ((GraphQLNonNull ) b ).getWrappedType ();
132- return isCompatible (a , wrappedB );
125+ } else if (constraintType instanceof GraphQLUnionType ) {
126+ return objectIsMemberOfUnion ((GraphQLUnionType ) constraintType , objectType );
127+ } else if (constraintType instanceof GraphQLInterfaceType && objectType instanceof GraphQLObjectType ) {
128+ return objectImplementsInterface ((GraphQLInterfaceType ) constraintType , (GraphQLObjectType ) objectType );
129+ } else if (constraintType instanceof GraphQLList && objectType instanceof GraphQLList ) {
130+ GraphQLOutputType wrappedConstraintType = (GraphQLOutputType ) ((GraphQLList ) constraintType ).getWrappedType ();
131+ GraphQLOutputType wrappedObjectType = (GraphQLOutputType ) ((GraphQLList ) objectType ).getWrappedType ();
132+ return isCompatible (wrappedConstraintType , wrappedObjectType );
133+ } else if (objectType instanceof GraphQLNonNull ) {
134+ GraphQLOutputType wrappedObjectType = (GraphQLOutputType ) ((GraphQLNonNull ) objectType ).getWrappedType ();
135+ return isCompatible (constraintType , wrappedObjectType );
133136 } else {
134137 return false ;
135138 }
0 commit comments