public List<GraphQLArgument> getBackwardPaginationConnectionFieldArguments() { List<GraphQLArgument> args = new ArrayList<>(); args.add(newArgument() .name("before") .description("fetching only nodes before this node (exclusive)") .type(GraphQLString) .build()); args.add(newArgument() .name("last") .description("fetching only the last certain number of nodes") .type(GraphQLInt) .build()); return args; }
public List<GraphQLArgument> getForwardPaginationConnectionFieldArguments() { List<GraphQLArgument> args = new ArrayList<>(); args.add(newArgument() .name("after") .description("fetching only nodes after this node (exclusive)") .type(GraphQLString) .build()); args.add(newArgument() .name("first") .description("fetching only the first certain number of nodes") .type(GraphQLInt) .build()); return args; }
public List<GraphQLArgument> getConnectionFieldArguments() { List<GraphQLArgument> args = new ArrayList<>(); args.add(newArgument() .name("before") .description("fetching only nodes before this node (exclusive)") .type(GraphQLString) .build()); args.add(newArgument() .name("after") .description("fetching only nodes after this node (exclusive)") .type(GraphQLString) .build()); args.add(newArgument() .name("first") .description("fetching only the first certain number of nodes") .type(GraphQLInt) .build()); args.add(newArgument() .name("last") .description("fetching only the last certain number of nodes") .type(GraphQLInt) .build()); return args; }
public GraphQLFieldDefinition nodeField(GraphQLInterfaceType nodeInterface, DataFetcher nodeDataFetcher) { return newFieldDefinition() .name("node") .description("Fetches an object given its ID") .type(nodeInterface) .dataFetcher(nodeDataFetcher) .argument(newArgument() .name("id") .description("The ID of an object") .type(nonNull(GraphQLID))) .build(); }
/** * Return the elasticsearch query argument. * * @return */ public GraphQLArgument createQueryArg() { return newArgument().name("query").description("Elasticsearch query to query the data.").type(GraphQLString).build(); }
public static GraphQLDirective mappedOperation(Operation operation) { return GraphQLDirective.newDirective() .name(MAPPED_OPERATION) .description("") .validLocation(Introspection.DirectiveLocation.FIELD_DEFINITION) .argument(GraphQLArgument.newArgument() .name(OPERATION) .description("") .value(operation) .type(UNREPRESENTABLE) .build()) .build(); }
private GraphQLArgument toGraphQLArgument(OperationArgument operationArgument, BuildContext buildContext) { GraphQLArgument argument = newArgument() .name(operationArgument.getName()) .description(operationArgument.getDescription()) .type(toGraphQLInputType(operationArgument.getJavaType(), buildContext)) .defaultValue(operationArgument.getDefaultValue()) .withDirectives(toGraphQLDirectives(operationArgument.getTypedElement(), buildContext.directiveBuilder::buildArgumentDefinitionDirectives, buildContext)) .build(); return buildContext.transformers.transform(argument, operationArgument, this, buildContext); }
public GraphQLArgument asArgument() { return GraphQLArgument.newArgument() .name(ARGUMENT_NAME) .description("Filter on property type and optional value pattern.") .type(new GraphQLTypeReference(PropertyFilter.class.getSimpleName())) .build(); }
/** * Return a new set of paging arguments. * * @return */ public List<GraphQLArgument> createPagingArgs() { List<GraphQLArgument> arguments = new ArrayList<>(); // #page arguments.add(newArgument().name("page").defaultValue(1L).description("Page to be selected").type(GraphQLLong).build()); // #perPage arguments.add(newArgument().name("perPage").description("Max count of elements per page").type(GraphQLLong).build()); return arguments; }
/** * Return a new name argument with the provided description. * * @param description * @return */ public GraphQLArgument createNameArg(String description) { return newArgument().name("name").type(GraphQLString).description(description).build(); }
/** * Return a new webroot path argument. * * @return */ public GraphQLArgument createPathArg() { return newArgument().name("path").type(GraphQLString).description("Webroot path which points to a container of a node.").build(); }
/** * Return a new argument for the uuid. * * @param description * @return */ public GraphQLArgument createUuidArg(String description) { return newArgument().name("uuid").type(GraphQLString).description(description).build(); }
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())); }
private GraphQLArgument getArgument(Attribute<?,?> attribute) { GraphQLType type = getAttributeType(attribute); String description = getSchemaDescription(attribute.getJavaMember()); if (type instanceof GraphQLInputType) { return GraphQLArgument.newArgument() .name(attribute.getName()) .type((GraphQLInputType) type) .description(description) .build(); } throw new IllegalArgumentException("Attribute " + attribute + " cannot be mapped as an Input Argument"); }
public GraphQLArgument getArgument(Field field, Class<?> containingClass) { GraphQLArgument.Builder builder = newArgument() .name(commonPropertiesCreator.getName(field)) .description(commonPropertiesCreator.getDescription(field)) .type(getType(field)); try { builder.defaultValue(getDefaultValue(field, containingClass)); } catch (IllegalAccessException | InstantiationException e) { throw new GraphQLAnnotationsException(e); } return builder.build(); }
private GraphQLArgument toGraphQLArgument(DirectiveArgument directiveArgument, BuildContext buildContext) { GraphQLArgument argument = newArgument() .name(directiveArgument.getName()) .description(directiveArgument.getDescription()) .type(toGraphQLInputType(directiveArgument.getJavaType(), buildContext)) .value(directiveArgument.getValue()) .defaultValue(directiveArgument.getDefaultValue()) .withDirectives(toGraphQLDirectives(directiveArgument.getTypedElement(), buildContext.directiveBuilder::buildArgumentDefinitionDirectives, buildContext)) .build(); return buildContext.transformers.transform(argument, directiveArgument, this, buildContext); }
.argument(GraphQLArgument.newArgument() .name("lat") .description("Latitude of the location") .type(Scalars.GraphQLFloat) .build()) .argument(GraphQLArgument.newArgument() .name("lon") .description("Longitude of the location") .type(Scalars.GraphQLFloat) .build()) .argument(GraphQLArgument.newArgument() .name("radius") .description("Radius (in meters) to search for from the specidied location") .type(Scalars.GraphQLInt) .build())
private GraphQLArgument buildArgument(BuildContext buildCtx, InputValueDefinition valueDefinition) { buildCtx.enterNode(valueDefinition); GraphQLArgument.Builder builder = GraphQLArgument.newArgument(); builder.definition(valueDefinition); builder.name(valueDefinition.getName()); builder.description(schemaGeneratorHelper.buildDescription(valueDefinition, valueDefinition.getDescription())); GraphQLInputType inputType = buildInputType(buildCtx, valueDefinition.getType()); builder.type(inputType); Value defaultValue = valueDefinition.getDefaultValue(); if (defaultValue != null) { builder.defaultValue(schemaGeneratorHelper.buildValue(defaultValue, inputType)); } builder.withDirectives( buildDirectives(valueDefinition.getDirectives(), emptyList(), ARGUMENT_DEFINITION, buildCtx.getDirectiveDefinitions()) ); GraphQLArgument argument = builder.build(); argument = directiveBehaviour.onArgument(argument, buildCtx.mkBehaviourParams()); return buildCtx.exitNode(argument); }
private List<GraphQLArgument> transferMissingArguments(List<GraphQLArgument> arguments, GraphQLDirective directiveDefinition) { Map<String, GraphQLArgument> declaredArgs = FpKit.getByName(arguments, GraphQLArgument::getName, FpKit.mergeFirst()); List<GraphQLArgument> argumentsOut = new ArrayList<>(arguments); for (GraphQLArgument directiveDefArg : directiveDefinition.getArguments()) { if (!declaredArgs.containsKey(directiveDefArg.getName())) { GraphQLArgument missingArg = GraphQLArgument.newArgument() .name(directiveDefArg.getName()) .description(directiveDefArg.getDescription()) .definition(directiveDefArg.getDefinition()) .type(directiveDefArg.getType()) .defaultValue(directiveDefArg.getDefaultValue()) .value(directiveDefArg.getDefaultValue()) .build(); argumentsOut.add(missingArg); } } return argumentsOut; }
public GraphQLFieldDefinition nodeField(GraphQLInterfaceType nodeInterface, DataFetcher nodeDataFetcher) { return newFieldDefinition() .name("node") .description("Fetches an object given its ID") .type(nodeInterface) .dataFetcher(nodeDataFetcher) .argument(newArgument() .name("id") .description("The ID of an object") .type(nonNull(GraphQLID))) .build(); }