use of graphql.schema.idl.errors.DirectiveIllegalLocationError in project graphql-java by graphql-java.
the class SchemaTypeChecker method checkDirectiveDefinitions.
private void checkDirectiveDefinitions(TypeDefinitionRegistry typeRegistry, List<GraphQLError> errors) {
List<DirectiveDefinition> directiveDefinitions = new ArrayList<>(typeRegistry.getDirectiveDefinitions().values());
directiveDefinitions.forEach(directiveDefinition -> {
List<InputValueDefinition> arguments = directiveDefinition.getInputValueDefinitions();
checkNamedUniqueness(errors, arguments, InputValueDefinition::getName, (name, arg) -> new NonUniqueNameError(directiveDefinition, arg));
List<Type> inputValueTypes = arguments.stream().map(InputValueDefinition::getType).collect(toList());
inputValueTypes.forEach(checkTypeExists(typeRegistry, errors, "directive definition", directiveDefinition, directiveDefinition.getName()));
directiveDefinition.getDirectiveLocations().forEach(directiveLocation -> {
String locationName = directiveLocation.getName();
try {
Introspection.DirectiveLocation.valueOf(locationName);
} catch (IllegalArgumentException e) {
errors.add(new DirectiveIllegalLocationError(directiveDefinition, locationName));
}
});
});
}
Aggregations