use of graphql.schema.idl.errors.DirectiveUnknownArgumentError in project graphql-java by graphql-java.
the class SchemaTypeDirectivesChecker method checkDirectiveArguments.
private void checkDirectiveArguments(List<GraphQLError> errors, TypeDefinitionRegistry typeRegistry, Node element, String elementName, Directive directive, DirectiveDefinition directiveDefinition) {
Map<String, InputValueDefinition> allowedArgs = getByName(directiveDefinition.getInputValueDefinitions(), (InputValueDefinition::getName), mergeFirst());
Map<String, Argument> providedArgs = getByName(directive.getArguments(), (Argument::getName), mergeFirst());
directive.getArguments().forEach(argument -> {
InputValueDefinition allowedArg = allowedArgs.get(argument.getName());
if (allowedArg == null) {
errors.add(new DirectiveUnknownArgumentError(element, elementName, directive.getName(), argument.getName()));
} else {
ArgValueOfAllowedTypeChecker argValueOfAllowedTypeChecker = new ArgValueOfAllowedTypeChecker(directive, element, elementName, argument, typeRegistry, runtimeWiring);
argValueOfAllowedTypeChecker.checkArgValueMatchesAllowedType(errors, argument.getValue(), allowedArg.getType());
}
});
allowedArgs.forEach((argName, definitionArgument) -> {
if (isNoNullArgWithoutDefaultValue(definitionArgument)) {
if (!providedArgs.containsKey(argName)) {
errors.add(new DirectiveMissingNonNullArgumentError(element, elementName, directive.getName(), argName));
}
}
});
}
Aggregations