• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java GraphQLOutputType类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中graphql.schema.GraphQLOutputType的典型用法代码示例。如果您正苦于以下问题:Java GraphQLOutputType类的具体用法?Java GraphQLOutputType怎么用?Java GraphQLOutputType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



GraphQLOutputType类属于graphql.schema包,在下文中一共展示了GraphQLOutputType类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: convertType

import graphql.schema.GraphQLOutputType; //导入依赖的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


示例2: getInputType

import graphql.schema.GraphQLOutputType; //导入依赖的package包/类
@Override
public GraphQLInputType getInputType(Type type) {
	GraphQLInputType rv;
	String typeName = this.getTypeNamingStrategy().getTypeName(this, type);
	if (getInputTypeCache().containsKey(typeName)) {
		return getInputTypeCache().get(typeName);
	}
	// check typemapper
	Optional<IGraphQLTypeMapper> typeMapper = getCustomTypeMapper(type);
	if (typeMapper.isPresent()) {
		rv = getInputTypeCache().put(typeName, typeMapper.get().getInputType(this, type));
	} else {
		GraphQLOutputType outputType = getOutputType(type);
		rv = getInputTypeCache().put(typeName, getInputType(outputType));
	}

	return rv;
}
 
开发者ID:bpatters,项目名称:schemagen-graphql,代码行数:19,代码来源:GraphQLObjectMapper.java


示例3: getListOutputMapping

import graphql.schema.GraphQLOutputType; //导入依赖的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


示例4: assertGenericListTypeMapping

import graphql.schema.GraphQLOutputType; //导入依赖的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


示例5: generateOutputType

import graphql.schema.GraphQLOutputType; //导入依赖的package包/类
protected GraphQLOutputType generateOutputType(Object object) {
    //An enum is a special case in both java and graphql,
    //and must be checked for while generating other kinds of types
    GraphQLEnumType enumType = generateEnumType(object);
    if (enumType != null) {
        return enumType;
    }
    
    List<GraphQLFieldDefinition> fields = getOutputFieldDefinitions(object);
    if (fields == null || fields.isEmpty()) {
        return null;
    }
    
    String typeName = getGraphQLTypeNameOrIdentityCode(object);
    GraphQLObjectType.Builder builder = newObject()
            .name(typeName)
            .fields(fields)
            .description(getTypeDescription(object));
    
    GraphQLInterfaceType[] interfaces = getInterfaces(object);
    if (interfaces != null) {
        builder.withInterfaces(interfaces);
    }
    return builder.build();
}
 
开发者ID:graphql-java,项目名称:graphql-java-type-generator,代码行数:26,代码来源:FullTypeGenerator.java


示例6: toGraphQLType

import graphql.schema.GraphQLOutputType; //导入依赖的package包/类
@Override
public GraphQLObjectType toGraphQLType(String typeName, AnnotatedType javaType, Set<Type> abstractTypes, OperationMapper operationMapper, BuildContext buildContext) {
    GraphQLObjectType.Builder typeBuilder = newObject()
            .name(typeName)
            .description(buildContext.typeInfoGenerator.generateTypeDescription(javaType));

    GraphQLType graphQLType = javaType.getAnnotation(GraphQLType.class);
    List<String> fieldOrder = graphQLType != null ? Arrays.asList(graphQLType.fieldOrder()) : Collections.emptyList();
    List<GraphQLFieldDefinition> fields = getFields(javaType, fieldOrder, buildContext, operationMapper);
    fields.forEach(typeBuilder::field);

    List<GraphQLOutputType> interfaces = getInterfaces(javaType, abstractTypes, fields, buildContext, operationMapper);
    interfaces.forEach(inter -> {
        if (inter instanceof GraphQLInterfaceType) {
            typeBuilder.withInterface((GraphQLInterfaceType) inter);
        } else {
            typeBuilder.withInterface((GraphQLTypeReference) inter);
        }
    });

    GraphQLObjectType type = new MappedGraphQLObjectType(typeBuilder.build(), javaType);
    interfaces.forEach(inter -> buildContext.typeRepository.registerCovariantType(inter.getName(), javaType, type));
    buildContext.typeRepository.registerObjectType(type);
    return type;
}
 
开发者ID:leangen,项目名称:graphql-spqr,代码行数:26,代码来源:ObjectTypeMapper.java


示例7: mapEntry

import graphql.schema.GraphQLOutputType; //导入依赖的package包/类
private GraphQLOutputType mapEntry(GraphQLOutputType keyType, GraphQLOutputType valueType, BuildContext buildContext) {
    String typeName = "mapEntry_" + keyType.getName() + "_" + valueType.getName();
    if (buildContext.knownTypes.contains(typeName)) {
        return new GraphQLTypeReference(typeName);
    }
    buildContext.knownTypes.add(typeName);

    return newObject()
            .name(typeName)
            .description("Map entry")
            .field(newFieldDefinition()
                    .name("key")
                    .description("Map key")
                    .type(keyType)
                    .build())
            .field(newFieldDefinition()
                    .name("value")
                    .description("Map value")
                    .type(valueType)
                    .build())
            .build();
}
 
开发者ID:leangen,项目名称:graphql-spqr,代码行数:23,代码来源:MapToListTypeAdapter.java


示例8: toGraphQLOperation

import graphql.schema.GraphQLOutputType; //导入依赖的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


示例9: testInlineUnion

import graphql.schema.GraphQLOutputType; //导入依赖的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


示例10: buildInstanceOutputType

import graphql.schema.GraphQLOutputType; //导入依赖的package包/类
@Override
public GraphQLOutputType buildInstanceOutputType(InstanceFieldBuilderContext instanceFieldBuilderContext,
                                                 InstanceOutputTypeService instanceOutputTypeService) {
    Map<String, Object> initValues = buildInitValuesMap();
    SchemaInstanceField target = getArrayEntryType().fieldFactory(getParent(), initValues);
    return new GraphQLList(target.buildInstanceOutputType(instanceFieldBuilderContext, instanceOutputTypeService));
}
 
开发者ID:nfl,项目名称:gold,代码行数:8,代码来源:ListType.java


示例11: FieldOfTypeConfig

import graphql.schema.GraphQLOutputType; //导入依赖的package包/类
public FieldOfTypeConfig(String name, String id, Service service, GraphQLOutputType graphqlOutputType, Boolean isList, String targetName) {

        this.name = name;
        this.id=id;
        this.service=service;
        this.graphqlOutputType = graphqlOutputType;
        this.targetName=targetName;
        this.isList=isList;

    }
 
开发者ID:semantic-integration,项目名称:hypergraphql,代码行数:11,代码来源:FieldOfTypeConfig.java


示例12: buildField

import graphql.schema.GraphQLOutputType; //导入依赖的package包/类
/**
 * Constructs a GraphQLField with a given name and type. 
 */
public static GraphQLFieldDefinition buildField(String name, GraphQLType type) { 
	return GraphQLFieldDefinition.newFieldDefinition()
		.type((GraphQLOutputType) type)
		.name(name)
		.build();
}
 
开发者ID:deptofdefense,项目名称:anet,代码行数:10,代码来源:GraphQLUtils.java


示例13: buildFieldWithArgs

import graphql.schema.GraphQLOutputType; //导入依赖的package包/类
/**
 * Builds a GraphQL Field on a field that takes arguments in order to fetch it. 
 * ie: Any @GraphQLFetcher annotated method that takes an argument. 
 */
public static GraphQLFieldDefinition buildFieldWithArgs(String fieldName, GraphQLType type, Class<?> beanClazz) {
	PropertyDataFetcherWithArgs dataFetcher = new PropertyDataFetcherWithArgs(fieldName, beanClazz);
	return GraphQLFieldDefinition.newFieldDefinition()
		.type((GraphQLOutputType) type)
		.name(fieldName)
		.dataFetcher(dataFetcher)
		.argument(dataFetcher.getValidArguments())
		.build();
}
 
开发者ID:deptofdefense,项目名称:anet,代码行数:14,代码来源:GraphQLUtils.java


示例14: getOutputType

import graphql.schema.GraphQLOutputType; //导入依赖的package包/类
@Override
public GraphQLOutputType getOutputType(IGraphQLObjectMapper graphQLObjectMapper, Type type) {
	if (type instanceof ParameterizedType) {
		ParameterizedType parameterizedType = (ParameterizedType) type;
		return new GraphQLList(graphQLObjectMapper.getOutputType(parameterizedType.getActualTypeArguments()[0]));
	} else {
		return new GraphQLList(graphQLObjectMapper.getOutputType(Object.class));
	}
}
 
开发者ID:bpatters,项目名称:schemagen-graphql,代码行数:10,代码来源:CollectionMapper.java


示例15: getOutputType

import graphql.schema.GraphQLOutputType; //导入依赖的package包/类
@Override
public GraphQLOutputType getOutputType(IGraphQLObjectMapper graphQLObjectMapper, Type type) {
	if (type instanceof ParameterizedType) {
		return getListOutputMapping(graphQLObjectMapper, type);
	} else {
		throw new NotMappableException(String.format("%s is not mappable to GraphQL", graphQLObjectMapper.getTypeNamingStrategy().getTypeName(graphQLObjectMapper, type)));
	}
}
 
开发者ID:bpatters,项目名称:schemagen-graphql,代码行数:9,代码来源:MapMapper.java


示例16: getOutputType

import graphql.schema.GraphQLOutputType; //导入依赖的package包/类
@Override
public GraphQLOutputType getOutputType(IGraphQLObjectMapper graphQLObjectMapper, Type type) {
	Class<?> classType = (Class<?>) type;
	Class<?> enumClassType = classType.getComponentType();
	GraphQLEnumType.Builder enumType = GraphQLEnumType.newEnum()
			.name(graphQLObjectMapper.getTypeNamingStrategy().getTypeName(graphQLObjectMapper, enumClassType));

	for (Object value : enumClassType.getEnumConstants()) {
		enumType.value(value.toString(), value);
	}
	return new GraphQLList(enumType.build());

}
 
开发者ID:bpatters,项目名称:schemagen-graphql,代码行数:14,代码来源:EnumSetMapper.java


示例17: testEnumType

import graphql.schema.GraphQLOutputType; //导入依赖的package包/类
@SuppressWarnings("serial")
@Test
public void testEnumType() {
	IGraphQLObjectMapper graphQLObjectMapper = newGraphQLObjectMapper(
			ImmutableList.<IGraphQLTypeMapper> builder().add(new TestTypeMapper()).addAll(GraphQLSchemaBuilder.getDefaultTypeMappers()).build());

	GraphQLOutputType outputType =  graphQLObjectMapper.getOutputType(new TypeToken<Enum>() {
	}.getType());

	assertEquals(Scalars.GraphQLString, outputType);
}
 
开发者ID:bpatters,项目名称:schemagen-graphql,代码行数:12,代码来源:GraphQLObjectMapperTest.java


示例18: assertGenericMapTypeMapping

import graphql.schema.GraphQLOutputType; //导入依赖的package包/类
private void assertGenericMapTypeMapping(String name, GraphQLOutputType expectedValueType, GraphQLOutputType graphQLOutputType) {

		GraphQLList listType = (GraphQLList) graphQLOutputType;

		// verify we contstructed an object from the map with the enum values as fields
		// and their type the expected value type
		assertEquals(GraphQLList.class, listType.getClass());
		GraphQLObjectType objectType = (GraphQLObjectType) listType.getWrappedType();

		assertEquals(name, objectType.getName());
		assertNotNull(objectType.getFieldDefinition(MapMapper.KEY_NAME));
		assertNotNull(objectType.getFieldDefinition(MapMapper.VALUE_NAME));
		assertEquals(expectedValueType.getClass(), objectType.getFieldDefinition(MapMapper.KEY_NAME).getType().getClass());
		assertEquals(expectedValueType.getClass(), objectType.getFieldDefinition(MapMapper.VALUE_NAME).getType().getClass());
	}
 
开发者ID:bpatters,项目名称:schemagen-graphql,代码行数:16,代码来源:GraphQLObjectMapper_CollectionsTest.java


示例19: test_getOutputType

import graphql.schema.GraphQLOutputType; //导入依赖的package包/类
@Test
public void test_getOutputType() throws Exception {
    // given
    ConnectionCursorMapper cut = createCut();

    // when
    GraphQLOutputType result = cut.getOutputType(null, null);

    // then
    assertEquals(result, Scalars.GraphQLString);
}
 
开发者ID:bpatters,项目名称:schemagen-graphql,代码行数:12,代码来源:ConnectionCursorMapperTest.java


示例20: test_getInputType

import graphql.schema.GraphQLOutputType; //导入依赖的package包/类
@Test
public void test_getInputType() throws Exception {
    // given
    ConnectionCursorMapper cut = createCut();

    // when
    GraphQLOutputType result = cut.getOutputType(null, null);

    // then
    assertEquals(result, Scalars.GraphQLString);
}
 
开发者ID:bpatters,项目名称:schemagen-graphql,代码行数:12,代码来源:ConnectionCursorMapperTest.java



注:本文中的graphql.schema.GraphQLOutputType类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ApplicationProtocolNames类代码示例发布时间:2022-05-21
下一篇:
Java VehicleMoveEvent类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap