use of graphql.language.Argument in project graphql-java by graphql-java.
the class ProvidedNonNullArguments method checkDirective.
@Override
public void checkDirective(Directive directive, List<Node> ancestors) {
GraphQLDirective graphQLDirective = getValidationContext().getDirective();
if (graphQLDirective == null)
return;
Map<String, Argument> argumentMap = argumentMap(directive.getArguments());
for (GraphQLArgument graphQLArgument : graphQLDirective.getArguments()) {
Argument argument = argumentMap.get(graphQLArgument.getName());
if (argument == null && (graphQLArgument.getType() instanceof GraphQLNonNull)) {
String message = String.format("Missing directive argument %s", graphQLArgument.getName());
addError(ValidationErrorType.MissingDirectiveArgument, directive.getSourceLocation(), message);
}
}
}
use of graphql.language.Argument in project graphql-java by graphql-java.
the class ProvidedNonNullArguments method checkField.
@Override
public void checkField(Field field) {
GraphQLFieldDefinition fieldDef = getValidationContext().getFieldDef();
if (fieldDef == null)
return;
Map<String, Argument> argumentMap = argumentMap(field.getArguments());
for (GraphQLArgument graphQLArgument : fieldDef.getArguments()) {
Argument argument = argumentMap.get(graphQLArgument.getName());
if (argument == null && (graphQLArgument.getType() instanceof GraphQLNonNull)) {
String message = String.format("Missing field argument %s", graphQLArgument.getName());
addError(ValidationErrorType.MissingFieldArgument, field.getSourceLocation(), message);
}
}
}
use of graphql.language.Argument in project graphql-java by graphql-java.
the class GraphqlAntlrToLanguage method visitArgument.
@Override
public Void visitArgument(GraphqlParser.ArgumentContext ctx) {
Argument argument = new Argument(ctx.name().getText(), getValue(ctx.valueWithVariable()));
newNode(argument, ctx);
if (getFromContextStack(ContextProperty.Directive, false) != null) {
((Directive) getFromContextStack(ContextProperty.Directive)).getArguments().add(argument);
} else {
Field field = (Field) getFromContextStack(ContextProperty.Field);
field.getArguments().add(argument);
}
return super.visitArgument(ctx);
}
use of graphql.language.Argument in project graphql-java by graphql-java.
the class IntrospectionResultToSchema method createDeprecatedDirective.
private void createDeprecatedDirective(Map<String, Object> field, List<Directive> directives) {
if ((Boolean) field.get("isDeprecated")) {
String reason = (String) field.get("deprecationReason");
if (reason == null) {
// default according to spec
reason = "No longer supported";
}
Argument reasonArg = new Argument("reason", new StringValue(reason));
Directive deprecated = new Directive("deprecated", Collections.singletonList(reasonArg));
directives.add(deprecated);
}
}
Aggregations