本文整理汇总了Java中graphql.schema.GraphQLList类的典型用法代码示例。如果您正苦于以下问题:Java GraphQLList类的具体用法?Java GraphQLList怎么用?Java GraphQLList使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GraphQLList类属于graphql.schema包,在下文中一共展示了GraphQLList类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getAllTypes
import graphql.schema.GraphQLList; //导入依赖的package包/类
@SuppressWarnings("JdkObsolete")
static Set<GraphQLType> getAllTypes(GraphQLSchema schema) {
LinkedHashSet<GraphQLType> types = new LinkedHashSet<>();
LinkedList<GraphQLObjectType> loop = new LinkedList<>();
loop.add(schema.getQueryType());
types.add(schema.getQueryType());
while (!loop.isEmpty()) {
for (GraphQLFieldDefinition field : loop.pop().getFieldDefinitions()) {
GraphQLType type = field.getType();
if (type instanceof GraphQLList) {
type = ((GraphQLList) type).getWrappedType();
}
if (!types.contains(type)) {
if (type instanceof GraphQLEnumType) {
types.add(field.getType());
}
if (type instanceof GraphQLObjectType) {
types.add(type);
loop.add((GraphQLObjectType) type);
}
}
}
}
return types;
}
开发者ID:google,项目名称:rejoiner,代码行数:27,代码来源:SchemaToProto.java
示例2: get
import graphql.schema.GraphQLList; //导入依赖的package包/类
@Override
public Object get(DataFetchingEnvironment environment) {
Object source = environment.getSource();
if (source == null) {
return null;
}
if (source instanceof Map) {
return ((Map<?, ?>) source).get(name);
}
GraphQLType type = environment.getFieldType();
if (type instanceof GraphQLNonNull) {
type = ((GraphQLNonNull) type).getWrappedType();
}
if (type instanceof GraphQLList) {
return call(source, "get" + LOWER_CAMEL_TO_UPPER.convert(name) + "List");
}
if (type instanceof GraphQLEnumType) {
Object o = call(source, "get" + LOWER_CAMEL_TO_UPPER.convert(name));
if (o != null) {
return o.toString();
}
}
return call(source, "get" + LOWER_CAMEL_TO_UPPER.convert(name));
}
开发者ID:google,项目名称:rejoiner,代码行数:26,代码来源:ProtoToGql.java
示例3: convertType
import graphql.schema.GraphQLList; //导入依赖的package包/类
/** Returns a GraphQLOutputType generated from a FieldDescriptor. */
static GraphQLOutputType convertType(FieldDescriptor fieldDescriptor) {
final GraphQLOutputType type;
if (fieldDescriptor.getType() == Type.MESSAGE) {
type = getReference(fieldDescriptor.getMessageType());
} else if (fieldDescriptor.getType() == Type.GROUP) {
type = getReference(fieldDescriptor.getMessageType());
} else if (fieldDescriptor.getType() == Type.ENUM) {
type = getReference(fieldDescriptor.getEnumType());
} else {
type = TYPE_MAP.get(fieldDescriptor.getType());
}
if (type == null) {
throw new RuntimeException("Unknown type: " + fieldDescriptor.getType());
}
if (fieldDescriptor.isRepeated()) {
return new GraphQLList(type);
} else {
return type;
}
}
开发者ID:google,项目名称:rejoiner,代码行数:25,代码来源:ProtoToGql.java
示例4: completeValueForList
import graphql.schema.GraphQLList; //导入依赖的package包/类
/**
* If the result is a list, then it's elements can now potentially be a {@link CompletableFuture}.
* To reduce the number of tasks in progress, it behooves us to wait for all those completable
* elements to wrap up.
*
* @return the completed execution result
*/
@Override
protected ExecutionResult completeValueForList(ExecutionContext executionContext,
GraphQLList fieldType,
List<Field> fields, Iterable<Object> result) {
ExecutionResult executionResult =
super.completeValueForList(executionContext, fieldType, fields, result);
List<Object> completableResults = (List<Object>) executionResult.getData();
List<Object> completedResults = new ArrayList<>();
completableResults.forEach(completedResult -> {
completedResults.add((completedResult instanceof CompletableFuture) ?
((CompletableFuture) completedResult).join() : completedResult);
});
((ExecutionResultImpl) executionResult).setData(completedResults);
return executionResult;
}
开发者ID:karthicks,项目名称:graphql-java-async,代码行数:23,代码来源:AsyncExecutionStrategy.java
示例5: getListOutputMapping
import graphql.schema.GraphQLList; //导入依赖的package包/类
private GraphQLOutputType getListOutputMapping(final IGraphQLObjectMapper graphQLObjectMapper, final Type type) {
ParameterizedType pType = (ParameterizedType) type;
GraphQLObjectType objectType = GraphQLObjectType.newObject()
.name(graphQLObjectMapper.getTypeNamingStrategy().getTypeName(graphQLObjectMapper, type))
.field(GraphQLFieldDefinition.newFieldDefinition()
.name(KEY_NAME)
.type(graphQLObjectMapper.getOutputType(pType.getActualTypeArguments()[0]))
.build())
.field(GraphQLFieldDefinition.newFieldDefinition()
.name(VALUE_NAME)
.type(graphQLObjectMapper.getOutputType(pType.getActualTypeArguments()[1]))
.build())
.build();
return new GraphQLList(objectType);
}
开发者ID:bpatters,项目名称:schemagen-graphql,代码行数:17,代码来源:MapMapper.java
示例6: getListInputMapping
import graphql.schema.GraphQLList; //导入依赖的package包/类
private GraphQLInputType getListInputMapping(final IGraphQLObjectMapper graphQLObjectMapper, final Type type) {
ParameterizedType pType = (ParameterizedType) type;
GraphQLInputObjectType objectType = GraphQLInputObjectType.newInputObject()
.name(graphQLObjectMapper.getTypeNamingStrategy().getTypeName(graphQLObjectMapper, type))
.field(GraphQLInputObjectField.newInputObjectField()
.name(KEY_NAME)
.type(graphQLObjectMapper.getInputType(pType.getActualTypeArguments()[0]))
.build())
.field(GraphQLInputObjectField.newInputObjectField()
.name(VALUE_NAME)
.type(graphQLObjectMapper.getInputType(pType.getActualTypeArguments()[1]))
.build())
.build();
return new GraphQLList(objectType);
}
开发者ID:bpatters,项目名称:schemagen-graphql,代码行数:17,代码来源:MapMapper.java
示例7: testRelayConnectionType
import graphql.schema.GraphQLList; //导入依赖的package包/类
@SuppressWarnings("serial")
@Test
public void testRelayConnectionType() {
IGraphQLObjectMapper graphQLObjectMapper = newGraphQLObjectMapper(Optional.<ITypeNamingStrategy> of(new RelayTypeNamingStrategy()));
GraphQLObjectType type = (GraphQLObjectType) graphQLObjectMapper.getOutputType(new TypeToken<RelayConnection<String>>() {
}.getType());
assertEquals("Relay_String_Connection", type.getName());
assertNotNull(type.getFieldDefinition("edges"));
assertNotNull(type.getFieldDefinition("pageInfo"));
assertEquals(GraphQLList.class, type.getFieldDefinition("edges").getType().getClass());
assertEquals("Edge_String", ((GraphQLList) type.getFieldDefinition("edges").getType()).getWrappedType().getName());
assertEquals(GraphQLObjectType.class, ((GraphQLList) type.getFieldDefinition("edges").getType()).getWrappedType().getClass());
GraphQLObjectType edgeObject = (GraphQLObjectType) ((GraphQLList) type.getFieldDefinition("edges").getType()).getWrappedType();
assertNotNull(edgeObject.getFieldDefinition("node"));
assertNotNull(edgeObject.getFieldDefinition("cursor"));
assertEquals(Scalars.GraphQLString, edgeObject.getFieldDefinition("node").getType());
assertEquals(Scalars.GraphQLString, edgeObject.getFieldDefinition("cursor").getType());
}
开发者ID:bpatters,项目名称:schemagen-graphql,代码行数:20,代码来源:GraphQLObjectMapperTest.java
示例8: testMethodBasedFields
import graphql.schema.GraphQLList; //导入依赖的package包/类
@SuppressWarnings("serial")
@Test
public void testMethodBasedFields() {
IGraphQLObjectMapper graphQLObjectMapper = newGraphQLObjectMapper(
ImmutableList.<IGraphQLTypeMapper> builder().add(new TestTypeMapper()).addAll(GraphQLSchemaBuilder.getDefaultTypeMappers()).build());
GraphQLObjectType objectType = (GraphQLObjectType) graphQLObjectMapper.getOutputType(new TypeToken<MethodBasedFields>() {
}.getType());
assertEquals(MethodBasedFields.class.getSimpleName(), objectType.getName());
assertEquals(2, objectType.getFieldDefinitions().size());
assertNotNull(objectType.getFieldDefinition("stringField"));
assertEquals(Scalars.GraphQLString, objectType.getFieldDefinition("stringField").getType());
assertNotNull(objectType.getFieldDefinition("stringList"));
assertEquals(GraphQLList.class, objectType.getFieldDefinition("stringList").getType().getClass());
assertEquals(Scalars.GraphQLString, ((GraphQLList) objectType.getFieldDefinition("stringList").getType()).getWrappedType());
assertNull(objectType.getFieldDefinition("ignoredObject"));
assertEquals(DefaultMethodDataFetcher.class, objectType.getFieldDefinition("stringField").getDataFetcher().getClass());
assertEquals(CollectionConverterDataFetcher.class, objectType.getFieldDefinition("stringList").getDataFetcher().getClass());
}
开发者ID:bpatters,项目名称:schemagen-graphql,代码行数:22,代码来源:GraphQLObjectMapperTest.java
示例9: testMethodOnlyFields
import graphql.schema.GraphQLList; //导入依赖的package包/类
@SuppressWarnings("serial")
@Test
public void testMethodOnlyFields() {
IGraphQLObjectMapper graphQLObjectMapper = newGraphQLObjectMapper(
ImmutableList.<IGraphQLTypeMapper> builder().add(new TestTypeMapper()).addAll(GraphQLSchemaBuilder.getDefaultTypeMappers()).build());
GraphQLObjectType objectType = (GraphQLObjectType) graphQLObjectMapper.getOutputType(new TypeToken<MethodOnlyFields>() {
}.getType());
assertEquals(MethodOnlyFields.class.getSimpleName(), objectType.getName());
assertEquals(2, objectType.getFieldDefinitions().size());
assertNotNull(objectType.getFieldDefinition("stringField"));
assertEquals(Scalars.GraphQLString, objectType.getFieldDefinition("stringField").getType());
assertNotNull(objectType.getFieldDefinition("stringList"));
assertEquals(GraphQLList.class, objectType.getFieldDefinition("stringList").getType().getClass());
assertEquals(Scalars.GraphQLString, ((GraphQLList) objectType.getFieldDefinition("stringList").getType()).getWrappedType());
assertNull(objectType.getFieldDefinition("ignoredObject"));
assertEquals(DefaultMethodDataFetcher.class, objectType.getFieldDefinition("stringField").getDataFetcher().getClass());
assertEquals(CollectionConverterDataFetcher.class, objectType.getFieldDefinition("stringList").getDataFetcher().getClass());
}
开发者ID:bpatters,项目名称:schemagen-graphql,代码行数:22,代码来源:GraphQLObjectMapperTest.java
示例10: assertGenericListTypeMapping
import graphql.schema.GraphQLList; //导入依赖的package包/类
private void assertGenericListTypeMapping(String name, GraphQLOutputType expectedWrappedType, GraphQLOutputType graphQLOutputType) {
assertEquals(GraphQLList.class, graphQLOutputType.getClass());
GraphQLList listType = (GraphQLList) graphQLOutputType;
GraphQLType wrappedType = listType.getWrappedType();
assertEquals(name, wrappedType.getName());
assertEquals(expectedWrappedType.getClass(), wrappedType.getClass());
if (expectedWrappedType instanceof GraphQLObjectType) {
GraphQLObjectType objectType = (GraphQLObjectType) wrappedType;
assertEquals("field1", objectType.getFieldDefinition("field1").getName());
assertEquals(Scalars.GraphQLString, objectType.getFieldDefinition("field1").getType());
assertEquals("field2", objectType.getFieldDefinition("field2").getName());
assertEquals(Scalars.GraphQLInt, objectType.getFieldDefinition("field2").getType());
}
}
开发者ID:bpatters,项目名称:schemagen-graphql,代码行数:19,代码来源:GraphQLObjectMapper_CollectionsTest.java
示例11: testRecursiveTypes
import graphql.schema.GraphQLList; //导入依赖的package包/类
@SuppressWarnings("serial")
@Test
public void testRecursiveTypes() {
GraphQLList listType = (GraphQLList) graphQLObjectMapper
.getOutputType(new TypeToken<Map<TestEnum, List<List<List<List<List<List<String>>>>>>>>() {
}.getType());
GraphQLObjectType outputType = (GraphQLObjectType) listType.getWrappedType();
assertEquals("Map_TestEnum_List_List_List_List_List_List_String", outputType.getName());
GraphQLEnumType keyType = (GraphQLEnumType) outputType.getFieldDefinition(MapMapper.KEY_NAME).getType();
GraphQLType valueType = outputType.getFieldDefinition(MapMapper.VALUE_NAME).getType();
int depth = 0;
while (valueType.getClass() == GraphQLList.class) {
depth++;
valueType = ((GraphQLList) valueType).getWrappedType();
}
assertEquals(6, depth);
// now we verify the key type
assertEquals(Scalars.GraphQLString, valueType);
}
开发者ID:bpatters,项目名称:schemagen-graphql,代码行数:23,代码来源:GraphQLObjectMapper_CollectionsTest.java
示例12: testInlineUnion
import graphql.schema.GraphQLList; //导入依赖的package包/类
@Test
public void testInlineUnion() {
InlineUnionService unionService = new InlineUnionService();
GraphQLSchema schema = new TestSchemaGenerator()
.withTypeAdapters(new MapToListTypeAdapter<>(new ObjectScalarStrategy()))
.withDefaults()
.withOperationsFromSingleton(unionService)
.generate();
GraphQLOutputType fieldType = schema.getQueryType().getFieldDefinition("union").getType();
assertNonNull(fieldType, GraphQLList.class);
GraphQLType list = ((graphql.schema.GraphQLNonNull) fieldType).getWrappedType();
assertListOf(list, GraphQLList.class);
GraphQLType map = ((GraphQLList) list).getWrappedType();
assertMapOf(map, GraphQLUnionType.class, GraphQLUnionType.class);
GraphQLObjectType entry = ((GraphQLObjectType) ((GraphQLList) map).getWrappedType());
GraphQLOutputType key = entry.getFieldDefinition("key").getType();
GraphQLOutputType value = entry.getFieldDefinition("value").getType();
assertEquals("Simple_One_Two", key.getName());
assertEquals("nice", ((GraphQLUnionType) key).getDescription());
assertEquals(value.getName(), "Education_Street");
assertUnionOf(key, schema.getType("SimpleOne"), schema.getType("SimpleTwo"));
assertUnionOf(value, schema.getType("Education"), schema.getType("Street"));
}
开发者ID:leangen,项目名称:graphql-spqr,代码行数:26,代码来源:UnionTest.java
示例13: completeValueForList
import graphql.schema.GraphQLList; //导入依赖的package包/类
@Override
protected ExecutionResult completeValueForList(ExecutionContext executionContext, GraphQLList fieldType, List<Field> fields, List<Object> result) {
Observable<?> resultObservable =
Observable.from(
IntStream.range(0, result.size())
.mapToObj(idx -> new ListTuple(idx, result.get(idx)))
.toArray(ListTuple[]::new)
)
.flatMap(tuple -> {
ExecutionResult executionResult = completeValue(executionContext, fieldType.getWrappedType(), fields, tuple.result);
if (executionResult instanceof RxExecutionResult) {
return Observable.zip(Observable.just(tuple.index), ((RxExecutionResult)executionResult).getDataObservable(), ListTuple::new);
}
return Observable.just(new ListTuple(tuple.index, executionResult.getData()));
})
.toList()
.map(listTuples -> {
return listTuples.stream()
.sorted(Comparator.comparingInt(x -> x.index))
.map(x -> x.result)
.collect(Collectors.toList());
});
return new RxExecutionResult(resultObservable, null);
}
开发者ID:nfl,项目名称:graphql-rxjava,代码行数:27,代码来源:RxExecutionStrategy.java
示例14: buildInputObjectArgument
import graphql.schema.GraphQLList; //导入依赖的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
示例15: instances
import graphql.schema.GraphQLList; //导入依赖的package包/类
private GraphQLFieldDefinition instances() {
return newFieldDefinition().name(Introspector.decapitalize(English.plural(name)))
.description(String.format("Return the instances of %s",
name))
.argument(newArgument().name(IDS)
.description("list of ids of the instances to query")
.type(new GraphQLList(GraphQLUuid))
.build())
.type(new GraphQLList(referenceToType(facet)))
.dataFetcher(context -> {
@SuppressWarnings("unchecked")
List<UUID> ids = (List<UUID>) context.getArgument(ID);
return (ids != null ? ctx(context).lookupList(ids)
: ctx(context).getInstances(facet)).stream()
.collect(Collectors.toList());
})
.build();
}
开发者ID:ChiralBehaviors,项目名称:Ultrastructure,代码行数:20,代码来源:FacetFields.java
示例16: setChildren
import graphql.schema.GraphQLList; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private void setChildren(NetworkAuthorization auth) {
String setter = String.format(SET_TEMPLATE,
Phantasmagoria.capitalized(auth.plural()));
GraphQLInputObjectField field = newInputObjectField().type(new GraphQLList(GraphQLUuid))
.name(setter)
.description(auth.getNotes())
.build();
updateTypeBuilder.field(field);
createTypeBuilder.field(field);
updateTemplate.put(setter,
(crud,
update) -> crud.setChildren(facet,
((Phantasm) update.get(AT_RULEFORM)).getRuleform(),
auth,
crud.lookupList((List<UUID>) update.get(setter))));
}
开发者ID:ChiralBehaviors,项目名称:Ultrastructure,代码行数:18,代码来源:FacetFields.java
示例17: typeOf
import graphql.schema.GraphQLList; //导入依赖的package包/类
private GraphQLOutputType typeOf(Attribute attribute) {
GraphQLOutputType type = null;
switch (attribute.getValueType()) {
case Binary:
type = GraphQLString; // encoded binary
break;
case Boolean:
type = GraphQLBoolean;
break;
case Integer:
type = GraphQLInt;
break;
case Numeric:
type = GraphQLFloat;
break;
case Text:
type = GraphQLString;
break;
case Timestamp:
type = GraphQLString;
break;
case JSON:
type = WorkspaceScalarTypes.GraphQLJson;
}
return attribute.getIndexed() ? new GraphQLList(type) : type;
}
开发者ID:ChiralBehaviors,项目名称:Ultrastructure,代码行数:27,代码来源:FacetFields.java
示例18: test_helloWorldCollection
import graphql.schema.GraphQLList; //导入依赖的package包/类
@Test
public void test_helloWorldCollection(TestContext context) {
Async async = context.async();
GraphQLObjectType query = GraphQLObjectType.newObject()
.name("query")
.field(GraphQLFieldDefinition.newFieldDefinition()
.name("helloList")
.type(new GraphQLList(Scalars.GraphQLString))
.dataFetcher((env) -> {
return Arrays.asList("a", "b", "c");
}))
.build();
GraphQLSchema schema = GraphQLSchema.newSchema()
.query(query)
.build();
AsyncGraphQLExec asyncGraphQL = AsyncGraphQLExec.create(schema);
Future<JsonObject> queryResult = asyncGraphQL.executeQuery("query { helloList }", null, null, null);
queryResult.setHandler(res -> {
JsonObject json = res.result();
JsonArray jsonArray = json.getJsonArray("helloList");
JsonArray expected = new JsonArray(Arrays.asList("a", "b", "c"));
context.assertEquals(expected, jsonArray);
async.complete();
});
}
开发者ID:tibor-kocsis,项目名称:vertx-graphql-utils,代码行数:29,代码来源:AsyncGraphQLExecTest.java
示例19: test_helloWorldCollectionAsync
import graphql.schema.GraphQLList; //导入依赖的package包/类
@Test
public void test_helloWorldCollectionAsync(TestContext context) {
Async async = context.async();
AsyncDataFetcher<List<String>> asyncDataFetcher = (env, handler) -> {
vertx.<List<String>> executeBlocking(fut -> {
fut.complete(Arrays.asList("a", "b", "c"));
}, handler);
};
GraphQLObjectType query = GraphQLObjectType.newObject()
.name("query")
.field(GraphQLFieldDefinition.newFieldDefinition()
.name("helloList")
.type(new GraphQLList(Scalars.GraphQLString))
.dataFetcher(asyncDataFetcher))
.build();
GraphQLSchema schema = GraphQLSchema.newSchema()
.query(query)
.build();
AsyncGraphQLExec asyncGraphQL = AsyncGraphQLExec.create(schema);
Future<JsonObject> queryResult = asyncGraphQL.executeQuery("query { helloList }", null, null, null);
queryResult.setHandler(res -> {
JsonObject json = res.result();
JsonArray jsonArray = json.getJsonArray("helloList");
JsonArray expected = new JsonArray(Arrays.asList("a", "b", "c"));
context.assertEquals(expected, jsonArray);
async.complete();
});
}
开发者ID:tibor-kocsis,项目名称:vertx-graphql-utils,代码行数:33,代码来源:AsyncGraphQLExecTest.java
示例20: toType
import graphql.schema.GraphQLList; //导入依赖的package包/类
private static String toType(GraphQLType type) {
if (type instanceof GraphQLList) {
return toType(((GraphQLList) type).getWrappedType()) + "[]";
} else if (type instanceof GraphQLObjectType) {
return type.getName();
} else if (type instanceof GraphQLEnumType) {
return type.getName() + "Enum";
} else {
return TYPE_MAP.get(type.getName());
}
}
开发者ID:google,项目名称:rejoiner,代码行数:12,代码来源:SchemaToTypeScript.java
注:本文中的graphql.schema.GraphQLList类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论