private void checkObjectTypeExtensions(List<GraphQLError> errors, TypeDefinitionRegistry typeRegistry) {
        typeRegistry.objectTypeExtensions()
                .forEach((name, extensions) -> {
                            checkTypeExtensionHasCorrespondingType(errors, typeRegistry, name, extensions, ObjectTypeDefinition.class);
                            checkTypeExtensionDirectiveRedefinition(errors, typeRegistry, name, extensions, ObjectTypeDefinition.class);

                            extensions.forEach(extension -> {
                                List<FieldDefinition> fieldDefinitions = extension.getFieldDefinitions();
                                // field unique ness
                                checkNamedUniqueness(errors, extension.getFieldDefinitions(), FieldDefinition::getName,
                                        (namedField, fieldDef) -> new NonUniqueNameError(extension, fieldDef));

                                // field arg unique ness
                                extension.getFieldDefinitions().forEach(fld -> checkNamedUniqueness(errors, fld.getInputValueDefinitions(), InputValueDefinition::getName,
                                        (namedField, inputValueDefinition) -> new NonUniqueArgumentError(extension, fld, name)));

                                // directive checks
                                extension.getFieldDefinitions().forEach(fld -> checkNamedUniqueness(errors, fld.getDirectives(), Directive::getName,
                                        (directiveName, directive) -> new NonUniqueDirectiveError(extension, fld, directiveName)));

                                fieldDefinitions.forEach(fld -> fld.getDirectives().forEach(directive -> {
                                    checkDeprecatedDirective(errors, directive,
                                            () -> new InvalidDeprecationDirectiveError(extension, fld));

                                    checkNamedUniqueness(errors, directive.getArguments(), Argument::getName,
                                            (argumentName, argument) -> new NonUniqueArgumentError(extension, fld, argumentName));

                                }));

                                //
                                // fields must be unique within a type extension
                                forEachBut(extension, extensions,
                                        otherTypeExt -> checkForFieldRedefinition(errors, otherTypeExt, otherTypeExt.getFieldDefinitions(), fieldDefinitions));

                                //
                                // then check for field re-defs from the base type
                                Optional<ObjectTypeDefinition> baseTypeOpt = typeRegistry.getType(extension.getName(), ObjectTypeDefinition.class);
                                baseTypeOpt.ifPresent(baseTypeDef -> checkForFieldRedefinition(errors, extension, fieldDefinitions, baseTypeDef.getFieldDefinitions()));

                            });
                        }
                );
    }
private void checkObjectTypeExtensions ( List < GraphQLError > errors , TypeDefinitionRegistry typeRegistry ) { typeRegistry . objectTypeExtensions ( ) . forEach ( ( name , extensions ) -> { checkTypeExtensionHasCorrespondingType ( errors , typeRegistry , name , extensions , ObjectTypeDefinition . class ) ; checkTypeExtensionDirectiveRedefinition ( errors , typeRegistry , name , extensions , ObjectTypeDefinition . class ) ; extensions . forEach ( extension -> { List < FieldDefinition > fieldDefinitions = extension . getFieldDefinitions ( ) ; checkNamedUniqueness ( errors , extension . getFieldDefinitions ( ) , FieldDefinition :: getName , ( namedField , fieldDef ) -> new NonUniqueNameError ( extension , fieldDef ) ) ; extension . getFieldDefinitions ( ) . forEach ( fld -> checkNamedUniqueness ( errors , fld . getInputValueDefinitions ( ) , InputValueDefinition :: getName , ( namedField , inputValueDefinition ) -> new NonUniqueArgumentError ( extension , fld , name ) ) ) ; extension . getFieldDefinitions ( ) . forEach ( fld -> checkNamedUniqueness ( errors , fld . getDirectives ( ) , Directive :: getName , ( directiveName , directive ) -> new NonUniqueDirectiveError ( extension , fld , directiveName ) ) ) ; fieldDefinitions . forEach ( fld -> fld . getDirectives ( ) . forEach ( directive -> { checkDeprecatedDirective ( errors , directive , ( ) -> new InvalidDeprecationDirectiveError ( extension , fld ) ) ; checkNamedUniqueness ( errors , directive . getArguments ( ) , Argument :: getName , ( argumentName , argument ) -> new NonUniqueArgumentError ( extension , fld , argumentName ) ) ; } ) ) ; forEachBut ( extension , extensions , otherTypeExt -> checkForFieldRedefinition ( errors , otherTypeExt , otherTypeExt . getFieldDefinitions ( ) , fieldDefinitions ) ) ; Optional < ObjectTypeDefinition > baseTypeOpt = typeRegistry . getType ( extension . getName ( ) , ObjectTypeDefinition . class ) ; baseTypeOpt . ifPresent ( baseTypeDef -> checkForFieldRedefinition ( errors , extension , fieldDefinitions , baseTypeDef . getFieldDefinitions ( ) ) ) ; } ) ; } ) ; }
/*
Object type extensions have the potential to be invalid if incorrectly defined.

The named type must already be defined and must be an Object type.
The fields of an Object type extension must have unique names; no two fields may share the same name.
Any fields of an Object type extension must not be already defined on the original Object type.
Any directives provided must not already apply to the original Object type.
Any interfaces provided must not be already implemented by the original Object type.
The resulting extended object type must be a super-set of all interfaces it implements.