boolean isCompatible()

in src/main/com/intellij/lang/jsgraphql/types/schema/validation/TypesImplementInterfaces.java [224:256]


  boolean isCompatible(GraphQLOutputType constraintType, GraphQLOutputType objectType) {
    if (isSameType(constraintType, objectType)) {
      return true;
    }
    else if (constraintType instanceof GraphQLUnionType) {
      return objectIsMemberOfUnion((GraphQLUnionType)constraintType, objectType);
    }
    else if (constraintType instanceof GraphQLInterfaceType && objectType instanceof GraphQLObjectType) {
      return objectImplementsInterface((GraphQLInterfaceType)constraintType, (GraphQLObjectType)objectType);
    }
    else if (constraintType instanceof GraphQLInterfaceType && objectType instanceof GraphQLInterfaceType) {
      return interfaceImplementsInterface((GraphQLInterfaceType)constraintType, (GraphQLInterfaceType)objectType);
    }
    else if (isList(constraintType) && isList(objectType)) {
      GraphQLOutputType wrappedConstraintType = (GraphQLOutputType)unwrapOne(constraintType);
      GraphQLOutputType wrappedObjectType = (GraphQLOutputType)unwrapOne(objectType);
      return isCompatible(wrappedConstraintType, wrappedObjectType);
    }
    else if (isNonNull(objectType)) {
      GraphQLOutputType nullableConstraint;
      if (isNonNull(constraintType)) {
        nullableConstraint = (GraphQLOutputType)unwrapOne(constraintType);
      }
      else {
        nullableConstraint = constraintType;
      }
      GraphQLOutputType nullableObjectType = (GraphQLOutputType)unwrapOne(objectType);
      return isCompatible(nullableConstraint, nullableObjectType);
    }
    else {
      return false;
    }
  }