Source:
<code>private void validateUnion(GraphQLUnionType type, SchemaValidationErrorCollector errorCollector) { assertTypeName(type.getName(), errorCollector); UnionTypeDefinition definition = type.getDefinition(); if (definition == null) { return; } <START> List<Type> memberTypes = definition.getMemberTypes(); <END> if (memberTypes == null || memberTypes.size() == 0) { SchemaValidationError validationError = new SchemaValidationError(SchemaValidationErrorType.UnionTypeLackOfTypeError, String.format("Union type \"%s\" must include one or more unique member types.", type.getName())); errorCollector.addError(validationError); } List<String> typeNames = new ArrayList<>(); for (Type memberType : memberTypes) { String typeName = ((TypeName) memberType).getName(); GraphQLNamedType graphQLNamedType = schemaTypeHolder.get(typeName); if (!(graphQLNamedType instanceof GraphQLObjectType)) { SchemaValidationError validationError = new SchemaValidationError(SchemaValidationErrorType.InvalidUnionMemberTypeError, String.format("The member types of a Union type must all be Object base types. member type \"%s\" in Union \"%s\" is invalid.", ((TypeName) memberType).getName(), type.getName())); errorCollector.addError(validationError); } if (typeNames.contains(typeName)) { SchemaValidationError validationError = new SchemaValidationError(SchemaValidationErrorType.RepetitiveElementError, String.format("The member types of a Union type must be unique. member type \"%s\" in Union \"%s\" is not unique.", ((TypeName) memberType).getName(), type.getName())); errorCollector.addError(validationError); } typeNames.add(typeName); } }</code><technical_language>need check AST definition here. members of type enough</technical_language>

Target:
private void validateUnion(GraphQLUnionType type, SchemaValidationErrorCollector errorCollector) { assertTypeName(type.getName(), errorCollector); List<GraphQLNamedOutputType> memberTypes = type.getTypes(); if (memberTypes == null || memberTypes.size() == 0) { SchemaValidationError validationError = new SchemaValidationError(SchemaValidationErrorType.UnionTypeLackOfTypeError, String.format("Union type \"%s\" must include one or more unique member types.", type.getName())); errorCollector.addError(validationError); } Set<String> typeNames = new HashSet<>(); for (GraphQLNamedOutputType memberType : memberTypes) { String typeName = memberType.getName(); GraphQLNamedType graphQLNamedType = schemaTypeHolder.get(typeName); if (!(graphQLNamedType instanceof GraphQLObjectType)) { SchemaValidationError validationError = new SchemaValidationError(SchemaValidationErrorType.InvalidUnionMemberTypeError, String.format("The member types of a Union type must all be Object base types. member type \"%s\" in Union \"%s\" is invalid.", ((TypeName) memberType).getName(), type.getName())); errorCollector.addError(validationError); } if (typeNames.contains(typeName)) { SchemaValidationError validationError = new SchemaValidationError(SchemaValidationErrorType.RepetitiveElementError, String.format("The member types of a Union type must be unique. member type \"%s\" in Union \"%s\" is not unique.", ((TypeName) memberType).getName(), type.getName())); errorCollector.addError(validationError); } typeNames.add(typeName); } }