Java Code Examples for graphql.schema.GraphQLArgument#Builder
The following examples show how to use
graphql.schema.GraphQLArgument#Builder .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ArgumentsGenerator.java From graphql-java-type-generator with MIT License | 6 votes |
@Override public List<GraphQLArgument> getArguments(Object object) { List<GraphQLArgument> arguments = new ArrayList<GraphQLArgument>(); List<ArgContainer> argObjects = getArgRepresentativeObjects(object); if (argObjects == null) { return arguments; } Set<String> argNames = new HashSet<String>(); for (ArgContainer argObject : argObjects) { GraphQLArgument.Builder argBuilder = getArgument(argObject); if (argBuilder == null) { continue; } GraphQLArgument arg = argBuilder.build(); if (argNames.contains(arg.getName())) { continue; } argNames.add(arg.getName()); arguments.add(arg); } return arguments; }
Example 2
Source File: ArgumentsGenerator.java From graphql-java-type-generator with MIT License | 6 votes |
protected GraphQLArgument.Builder getArgument(ArgContainer argObject) { String name = getStrategies().getArgumentNameStrategy().getArgumentName(argObject); GraphQLInputType type = getStrategies().getArgumentTypeStrategy().getArgumentType(argObject); if (name == null || type == null) { return null; } String description = getStrategies().getArgumentDescriptionStrategy().getArgumentDescription(argObject); Object defaultValue = getStrategies().getArgumentDefaultValueStrategy().getArgumentDefaultValue(argObject); GraphQLArgument.Builder builder = GraphQLArgument.newArgument() .name(name) .type(type) .defaultValue(defaultValue) .description(description); return builder; }
Example 3
Source File: Bootstrap.java From smallrye-graphql with Apache License 2.0 | 5 votes |
private GraphQLArgument createGraphQLArgument(Argument argument) { GraphQLArgument.Builder argumentBuilder = GraphQLArgument.newArgument() .name(argument.getName()) .description(argument.getDescription()) .defaultValue(sanitizeDefaultValue(argument)); GraphQLInputType graphQLInputType = referenceGraphQLInputType(argument); // Collection if (argument.hasArray()) { Array array = argument.getArray(); // Mandatory in the collection if (array.isNotEmpty()) { graphQLInputType = GraphQLNonNull.nonNull(graphQLInputType); } // Collection depth for (int i = 0; i < array.getDepth(); i++) { graphQLInputType = GraphQLList.list(graphQLInputType); } } // Mandatory if (argument.isNotNull()) { graphQLInputType = GraphQLNonNull.nonNull(graphQLInputType); } argumentBuilder = argumentBuilder.type(graphQLInputType); return argumentBuilder.build(); }
Example 4
Source File: Arguments.java From spring-boot-starter-graphql with Apache License 2.0 | 5 votes |
public static GraphQLArgument.Builder notNull (GraphQLArgument.Builder aBuilder) { GraphQLArgument arg = aBuilder.build(); return GraphQLArgument.newArgument() .name(arg.getName()) .defaultValue(arg.getDefaultValue()) .definition(arg.getDefinition()) .description(arg.getDescription()) .type(new GraphQLNonNull(arg.getType())); }
Example 5
Source File: Arguments.java From spring-boot-starter-graphql with Apache License 2.0 | 4 votes |
public static GraphQLArgument.Builder stringArgument (String aName) { return GraphQLArgument.newArgument() .name(aName) .type(Scalars.GraphQLString); }