use of graphql.schema.GraphQLAppliedDirectiveArgument in project graphql-java by graphql-java.
the class SchemaGeneratorAppliedDirectiveHelper method transferMissingAppliedArguments.
private static List<GraphQLAppliedDirectiveArgument> transferMissingAppliedArguments(List<GraphQLAppliedDirectiveArgument> arguments, GraphQLDirective directiveDefinition) {
Map<String, GraphQLAppliedDirectiveArgument> declaredArgs = FpKit.getByName(arguments, GraphQLAppliedDirectiveArgument::getName, FpKit.mergeFirst());
List<GraphQLAppliedDirectiveArgument> argumentsOut = new ArrayList<>(arguments);
for (GraphQLArgument directiveDefArg : directiveDefinition.getArguments()) {
if (!declaredArgs.containsKey(directiveDefArg.getName())) {
GraphQLAppliedDirectiveArgument.Builder missingArg = GraphQLAppliedDirectiveArgument.newArgument().name(directiveDefArg.getName()).type(directiveDefArg.getType()).description(directiveDefArg.getDescription());
if (directiveDefArg.hasSetDefaultValue()) {
missingArg.valueLiteral((Value<?>) directiveDefArg.getArgumentDefaultValue().getValue());
}
if (directiveDefArg.hasSetValue()) {
missingArg.valueLiteral((Value<?>) directiveDefArg.getArgumentValue().getValue());
}
argumentsOut.add(missingArg.build());
}
}
return argumentsOut;
}
use of graphql.schema.GraphQLAppliedDirectiveArgument in project graphql-java by graphql-java.
the class SchemaGeneratorAppliedDirectiveHelper method buildAppliedArg.
private static GraphQLAppliedDirectiveArgument buildAppliedArg(SchemaGeneratorHelper.BuildContext buildCtx, Argument arg, GraphQLDirective directiveDefinition) {
GraphQLArgument directiveDefArgument = directiveDefinition.getArgument(arg.getName());
GraphQLAppliedDirectiveArgument.Builder builder = GraphQLAppliedDirectiveArgument.newArgument();
builder.name(arg.getName()).type(directiveDefArgument.getType()).definition(buildCtx.isCaptureAstDefinitions() ? arg : null);
// we put the default value in if the specified is null
if (arg.getValue() != null) {
builder.valueLiteral(arg.getValue());
} else {
// we know it is a literal because it was created by SchemaGenerator
if (directiveDefArgument.getArgumentDefaultValue().isSet()) {
builder.valueLiteral((Value<?>) directiveDefArgument.getArgumentDefaultValue().getValue());
}
}
return builder.build();
}
Aggregations