本文整理汇总了Java中graphql.schema.GraphQLArgument类的典型用法代码示例。如果您正苦于以下问题:Java GraphQLArgument类的具体用法?Java GraphQLArgument怎么用?Java GraphQLArgument使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GraphQLArgument类属于graphql.schema包,在下文中一共展示了GraphQLArgument类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: buildValidArgs
import graphql.schema.GraphQLArgument; //导入依赖的package包/类
private void buildValidArgs(boolean isListFetcher) {
validArgs = new LinkedList<GraphQLArgument>();
validArgs.addAll(arguments.values());
//Only accept the f argument if we can actually do anything with it.
if (fetchers.size() > 0) {
String enumName = resource.getBeanClass().getSimpleName() + (isListFetcher ? "s" : "") + "_functions";
GraphQLEnumType.Builder functionNamesEnum = GraphQLEnumType.newEnum()
.name(enumName);
for (String functionName : fetchers.keySet()) {
functionNamesEnum.value(functionName);
}
validArgs.add(GraphQLArgument.newArgument()
.name("f")
.type(functionNamesEnum.build())
.build());
}
}
开发者ID:deptofdefense,项目名称:anet,代码行数:18,代码来源:AnetResourceDataFetcher.java
示例2: testMethodParameterRequired
import graphql.schema.GraphQLArgument; //导入依赖的package包/类
@SuppressWarnings("serial")
@Test
public void testMethodParameterRequired() {
IGraphQLObjectMapper graphQLObjectMapper = newGraphQLObjectMapper(
ImmutableList.<IGraphQLTypeMapper>builder().add(new TestTypeMapper()).addAll(GraphQLSchemaBuilder.getDefaultTypeMappers()).build());
GraphQLObjectType objectType = (GraphQLObjectType) graphQLObjectMapper.getOutputType(new TypeToken<MethodRequiredFields>() {
}.getType());
assertEquals(MethodRequiredFields.class.getSimpleName(), objectType.getName());
assertEquals(1, objectType.getFieldDefinitions().size());
assertNotNull(objectType.getFieldDefinition("method"));
List<GraphQLArgument> arguments = objectType.getFieldDefinition("method").getArguments();
assertEquals(2, arguments.size());
assertEquals(new GraphQLNonNull(Scalars.GraphQLString), arguments.get(0).getType());
assertEquals(Scalars.GraphQLString, arguments.get(1).getType());
}
开发者ID:bpatters,项目名称:schemagen-graphql,代码行数:19,代码来源:GraphQLObjectMapperTest.java
示例3: getArguments
import graphql.schema.GraphQLArgument; //导入依赖的package包/类
@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;
}
开发者ID:graphql-java,项目名称:graphql-java-type-generator,代码行数:25,代码来源:ArgumentsGenerator.java
示例4: getArgument
import graphql.schema.GraphQLArgument; //导入依赖的package包/类
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;
}
开发者ID:graphql-java,项目名称:graphql-java-type-generator,代码行数:17,代码来源:ArgumentsGenerator.java
示例5: toGraphQLOperation
import graphql.schema.GraphQLArgument; //导入依赖的package包/类
/**
* Maps a single operation to a GraphQL output field (as queries in GraphQL are nothing but fields of the root operation type).
*
* @param operation The operation to map to a GraphQL output field
* @param buildContext The shared context containing all the global information needed for mapping
*
* @return GraphQL output field representing the given operation
*/
public GraphQLFieldDefinition toGraphQLOperation(Operation operation, BuildContext buildContext) {
Set<Type> abstractTypes = new HashSet<>();
GraphQLOutputType type = toGraphQLType(operation.getJavaType(), abstractTypes, buildContext);
GraphQLFieldDefinition.Builder queryBuilder = newFieldDefinition()
.name(operation.getName())
.description(operation.getDescription())
.type(type);
List<GraphQLArgument> arguments = operation.getArguments().stream()
.filter(OperationArgument::isMappable)
.map(argument -> toGraphQLArgument(argument, abstractTypes, buildContext))
.collect(Collectors.toList());
queryBuilder.argument(arguments);
if (type.getName() != null && !type.getName().equals("Connection") && type.getName().endsWith("Connection")) {
if (buildContext.relay.getConnectionFieldArguments().stream()
.anyMatch(connArg -> arguments.stream()
.anyMatch(arg -> arg.getName().equals(connArg.getName()) && !arg.getType().getName().equals(connArg.getType().getName())))) {
throw new TypeMappingException("Operation \"" + operation.getName() + "\" has arguments of types incompatible with the Relay Connection spec");
}
}
ValueMapper valueMapper = buildContext.valueMapperFactory.getValueMapper(abstractTypes, buildContext.globalEnvironment);
queryBuilder.dataFetcher(createResolver(operation, valueMapper, buildContext.globalEnvironment));
return new MappedGraphQLFieldDefinition(queryBuilder.build(), operation);
}
开发者ID:leangen,项目名称:graphql-spqr,代码行数:34,代码来源:OperationMapper.java
示例6: call
import graphql.schema.GraphQLArgument; //导入依赖的package包/类
@Override
public List<GraphQLArgument> call(@Nullable Field field, Method method, Class declaringClass, Annotation annotation) {
// if same annotation is detected on both field and getter we fail. Only one annotation is allowed. We can talk about having precedence logic later.
if (method.isAnnotationPresent(annotation.annotationType()) && field != null && field.isAnnotationPresent(annotation.annotationType())) {
throw new IllegalArgumentException("Conflict: GraphQL Annotations can't be added to both field and getter. Pick one for "+
annotation.annotationType() + " on " + field.getName() + " and " + method.getName());
}
Type returnType = GenericTypeReflector.getExactReturnType(method, declaringClass);
if (returnType instanceof ParameterizedType) {
ParameterizedType parameterizedType = (ParameterizedType) returnType;
Type containerType = parameterizedType.getRawType();
if (Collection.class.isAssignableFrom((Class) containerType)) {
List<GraphQLArgument> arguments = new ArrayList<>();
arguments.add(newArgument().name(GlitrForwardPagingArguments.FIRST).type(GraphQLInt).build());
arguments.add(newArgument().name(GlitrForwardPagingArguments.AFTER).type(GraphQLString).build());
return arguments;
}
}
return new ArrayList<>();
}
开发者ID:nfl,项目名称:glitr,代码行数:24,代码来源:CustomFieldArgumentsFunc.java
示例7: buildInputObjectArgument
import graphql.schema.GraphQLArgument; //导入依赖的package包/类
/**
* Wraps a constructed GraphQL Input Object in an argument.
* @param entityClass - The class to construct the input object from.
* @param asList Whether or not the argument is a single instance or a list.
* @return The constructed argument.
*/
private GraphQLArgument buildInputObjectArgument(Class<?> entityClass, boolean asList) {
GraphQLInputType argumentType = inputObjectRegistry.get(entityClass);
if (asList) {
return newArgument()
.name(ARGUMENT_DATA)
.type(new GraphQLList(argumentType))
.build();
} else {
return newArgument()
.name(ARGUMENT_DATA)
.type(argumentType)
.build();
}
}
开发者ID:yahoo,项目名称:elide,代码行数:22,代码来源:ModelBuilder.java
示例8: test_helloWorld
import graphql.schema.GraphQLArgument; //导入依赖的package包/类
@Test
public void test_helloWorld(TestContext context) {
Async async = context.async();
GraphQLObjectType query = GraphQLObjectType.newObject()
.name("query")
.field(GraphQLFieldDefinition.newFieldDefinition()
.name("hello")
.type(Scalars.GraphQLString)
.argument(GraphQLArgument.newArgument().name("myparam").type(Scalars.GraphQLString).build())
.dataFetcher(environment -> {
return environment.getArgument("myparam");
}))
.build();
GraphQLSchema schema = GraphQLSchema.newSchema()
.query(query)
.build();
AsyncGraphQLExec asyncGraphQL = AsyncGraphQLExec.create(schema);
Map<String, Object> params = new HashMap<>();
params.put("p", "myvalue");
Future<JsonObject> queryResult = asyncGraphQL.executeQuery("query ($p: String) { hello(myparam: $p) }", null, null, params);
queryResult.setHandler(res -> {
JsonObject json = res.result();
context.assertEquals(new JsonObject().put("hello", "myvalue"), json);
async.complete();
});
}
开发者ID:tibor-kocsis,项目名称:vertx-graphql-utils,代码行数:31,代码来源:AsynGraphQLExecParamTest.java
示例9: inputConverterShouldCreateArgument
import graphql.schema.GraphQLArgument; //导入依赖的package包/类
@Test
public void inputConverterShouldCreateArgument() {
GqlInputConverter inputConverter =
GqlInputConverter.newBuilder().add(TestProto.getDescriptor().getFile()).build();
GraphQLArgument argument = inputConverter.createArgument(Proto1.getDescriptor(), "input");
Truth.assertThat(argument.getName()).isEqualTo("input");
Truth.assertThat(argument.getType().getName())
.isEqualTo("Input_javatests_com_google_api_graphql_rejoiner_proto_Proto1");
}
开发者ID:google,项目名称:rejoiner,代码行数:10,代码来源:GqlInputConverterTest.java
示例10: inputConverterShouldCreateArgumentForMessagesInSameFile
import graphql.schema.GraphQLArgument; //导入依赖的package包/类
@Test
public void inputConverterShouldCreateArgumentForMessagesInSameFile() {
GqlInputConverter inputConverter =
GqlInputConverter.newBuilder().add(TestProto.getDescriptor().getFile()).build();
GraphQLArgument argument = inputConverter.createArgument(Proto2.getDescriptor(), "input");
Truth.assertThat(argument.getName()).isEqualTo("input");
Truth.assertThat(argument.getType().getName())
.isEqualTo("Input_javatests_com_google_api_graphql_rejoiner_proto_Proto2");
}
开发者ID:google,项目名称:rejoiner,代码行数:10,代码来源:GqlInputConverterTest.java
示例11: getQueryType
import graphql.schema.GraphQLArgument; //导入依赖的package包/类
@Bean
@Qualifier("QueryType")
public GraphQLObjectType getQueryType() {
return newObject()
.name("QueryType")
.field(newFieldDefinition()
.name("users")
.type(list(getUserType()))
.dataFetcher(new UserListFetcher(userAdaptor))
.build())
.field(newFieldDefinition()
.name("products")
.type(list(getProductType()))
.dataFetcher(new ProductListFetcher(productAdaptor))
.build())
.field(newFieldDefinition()
.name("orders")
.type(list(getOrderType()))
.dataFetcher(new OrderListFetcher(orderAdaptor))
.build())
.field(newFieldDefinition()
.name("user")
.argument(GraphQLArgument.newArgument()
.name("userId")
.type(GraphQLString)
.build())
.type(getUserType())
.dataFetcher(new UserFetcher(userAdaptor))
.build())
.field(newFieldDefinition()
.name("product")
.argument(GraphQLArgument.newArgument()
.name("productId")
.type(GraphQLString)
.build())
.type(getProductType())
.dataFetcher(new ProductFetcher(productAdaptor))
.build())
.build();
}
开发者ID:roybailey,项目名称:research-graphql,代码行数:41,代码来源:ManualGraphQLQuerySchema.java
示例12: getMutationType
import graphql.schema.GraphQLArgument; //导入依赖的package包/类
@Bean
@Qualifier("MutationType")
public GraphQLObjectType getMutationType() {
return newObject()
.name("MutationType")
.field(newFieldDefinition()
.name("createProduct")
.type(productType)
.argument(GraphQLArgument.newArgument()
.name("name")
.type(GraphQLString)
.build())
.argument(GraphQLArgument.newArgument()
.name("price")
.type(GraphQLFloat)
.build())
.dataFetcher(new ProductUpsertFetcher(productAdaptor))
.build())
.field(newFieldDefinition()
.name("createProductObject")
.type(productType)
.argument(GraphQLArgument.newArgument()
.name("product")
.type(getInputProductType())
.build())
.dataFetcher(new ProductUpsertFetcher(productAdaptor))
.build())
.field(newFieldDefinition()
.name("deleteProduct")
.type(productType)
.argument(GraphQLArgument.newArgument()
.name("productId")
.type(GraphQLID)
.build())
.dataFetcher(new ProductDeleteFetcher(productAdaptor))
.build())
.build();
}
开发者ID:roybailey,项目名称:research-graphql,代码行数:39,代码来源:ManualGraphQLMutationSchema.java
示例13: getFieldFetcher
import graphql.schema.GraphQLArgument; //导入依赖的package包/类
@Override
public Object getFieldFetcher(Object object) {
Object fetcher = getNextStrategy().getFieldFetcher(object);
if (!(fetcher instanceof ArgAwareDataFetcher)) {
return fetcher;
}
List<GraphQLArgument> arguments = getContext()
.getArgumentsGeneratorStrategy().getArguments(object);
if (arguments == null || arguments.isEmpty()) {
return fetcher;
}
return new GraphQLInputAwareDataFetcher(
new ArgumentExtractingDataFetcher((ArgAwareDataFetcher) fetcher), arguments);
}
开发者ID:graphql-java,项目名称:graphql-java-type-generator,代码行数:16,代码来源:FieldDataFetcher_InputAndArgAware.java
示例14: getFieldFetcherFromMethod
import graphql.schema.GraphQLArgument; //导入依赖的package包/类
protected Object getFieldFetcherFromMethod(Method method, Object methodSource) {
MethodInvokingDataFetcher methodInvoker = new MethodInvokingDataFetcher(method);
methodInvoker.setSource(methodSource);
List<GraphQLArgument> arguments = getContext()
.getArgumentsGeneratorStrategy().getArguments(method);
if (arguments == null || arguments.isEmpty()) {
return methodInvoker;
}
return new GraphQLInputAwareDataFetcher(
new ArgumentExtractingDataFetcher(methodInvoker), arguments);
}
开发者ID:graphql-java,项目名称:graphql-java-type-generator,代码行数:12,代码来源:FieldDataFetcher_Reflection.java
示例15: getOutputFieldDefinition
import graphql.schema.GraphQLArgument; //导入依赖的package包/类
/**
* May return null should this field be disallowed
* @param object
* @return
*/
protected GraphQLFieldDefinition.Builder getOutputFieldDefinition(
final Object object) {
String fieldName = getFieldName(object);
GraphQLOutputType fieldType = (GraphQLOutputType)
getTypeOfField(object, TypeKind.OBJECT);
if (fieldName == null || fieldType == null) {
return null;
}
Object fieldFetcher = getFieldFetcher(object);
String fieldDescription = getFieldDescription(object);
String fieldDeprecation = getFieldDeprecation(object);
List<GraphQLArgument> fieldArguments = getFieldArguments(object);
logger.debug("GraphQL field will be of type [{}] and name [{}] and fetcher [{}] with description [{}]",
fieldType, fieldName, fieldFetcher, fieldDescription);
GraphQLFieldDefinition.Builder fieldBuilder = newFieldDefinition()
.name(fieldName)
.type(fieldType)
.description(fieldDescription)
.deprecate(fieldDeprecation);
if (fieldArguments != null) {
fieldBuilder.argument(fieldArguments);
}
if (fieldFetcher instanceof DataFetcher) {
fieldBuilder.dataFetcher((DataFetcher)fieldFetcher);
}
else if (fieldFetcher != null) {
fieldBuilder.staticValue(fieldFetcher);
}
return fieldBuilder;
}
开发者ID:graphql-java,项目名称:graphql-java-type-generator,代码行数:37,代码来源:FieldsGenerator.java
示例16: toGraphQLArgument
import graphql.schema.GraphQLArgument; //导入依赖的package包/类
private GraphQLArgument toGraphQLArgument(OperationArgument operationArgument, Set<Type> abstractTypes, BuildContext buildContext) {
Set<Type> argumentAbstractTypes = new HashSet<>();
GraphQLArgument.Builder argument = newArgument()
.name(operationArgument.getName())
.description(operationArgument.getDescription())
.type(toGraphQLInputType(operationArgument.getJavaType(), argumentAbstractTypes, buildContext));
abstractTypes.addAll(argumentAbstractTypes);
OperationArgumentDefaultValue defaultValue = operationArgument.getDefaultValue();
if (defaultValue.isPresent()) {
argument.defaultValue(defaultValue.get());
}
return argument.build();
}
开发者ID:leangen,项目名称:graphql-spqr,代码行数:15,代码来源:OperationMapper.java
示例17: testRootQueryArgumentTypeUniqueness
import graphql.schema.GraphQLArgument; //导入依赖的package包/类
private void testRootQueryArgumentTypeUniqueness(GraphQLSchema schema, Function<GraphQLType, GraphQLType> unwrapper) {
List<GraphQLType> inputTypes = schema.getQueryType().getFieldDefinitions().stream()
.flatMap(def -> def.getArguments().stream())
.map(GraphQLArgument::getType)
.map(unwrapper)
.collect(Collectors.toList());
assertEquals(2, inputTypes.size());
assertTrue(inputTypes.stream().allMatch(type -> inputTypes.get(0) == type));
}
开发者ID:leangen,项目名称:graphql-spqr,代码行数:10,代码来源:UniquenessTest.java
示例18: createPagingArgs
import graphql.schema.GraphQLArgument; //导入依赖的package包/类
/**
* 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").defaultValue(25).description("Max count of elements per page").type(GraphQLInt).build());
return arguments;
}
开发者ID:gentics,项目名称:mesh,代码行数:16,代码来源:AbstractTypeProvider.java
示例19: createLanguageTagArg
import graphql.schema.GraphQLArgument; //导入依赖的package包/类
/**
* Create a new argument for the lang.
*
* @return
*/
public GraphQLArgument createLanguageTagArg() {
// #lang
String defaultLanguage = Mesh.mesh().getOptions().getDefaultLanguage();
return newArgument().name("lang").type(new GraphQLList(GraphQLString)).description(
"Language tags to filter by. When set only nodes which contain at least one of the provided language tags will be returned")
.defaultValue(Arrays.asList(defaultLanguage)).build();
}
开发者ID:gentics,项目名称:mesh,代码行数:14,代码来源:AbstractTypeProvider.java
示例20: asArgument
import graphql.schema.GraphQLArgument; //导入依赖的package包/类
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();
}
开发者ID:nemerosa,项目名称:ontrack,代码行数:8,代码来源:GQLInputPropertyFilter.java
注:本文中的graphql.schema.GraphQLArgument类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论