use of graphql.schema.idl.errors.TypeExtensionDirectiveRedefinitionError in project graphql-java by graphql-java.
the class SchemaTypeExtensionsChecker method checkTypeExtensionDirectiveRedefinition.
@SuppressWarnings("unchecked")
private void checkTypeExtensionDirectiveRedefinition(List<GraphQLError> errors, TypeDefinitionRegistry typeRegistry, String name, List<? extends TypeDefinition> extensions, Class<? extends TypeDefinition> targetClass) {
Optional<? extends TypeDefinition> typeDefinition = typeRegistry.getType(new TypeName(name), targetClass);
if (typeDefinition.isPresent() && typeDefinition.get().getClass().equals(targetClass)) {
List<Directive> directives = typeDefinition.get().getDirectives();
Map<String, Directive> directiveMap = FpKit.getByName(directives, Directive::getName, mergeFirst());
extensions.forEach(typeExt -> {
List<Directive> extDirectives = typeExt.getDirectives();
extDirectives.forEach(directive -> {
if (directiveMap.containsKey(directive.getName())) {
errors.add(new TypeExtensionDirectiveRedefinitionError(typeDefinition.get(), directive));
}
});
});
}
}
Aggregations