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

Java GraphQLInputType类代码示例

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

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



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

示例1: getInputProductType

import graphql.schema.GraphQLInputType; //导入依赖的package包/类
@Bean
@Qualifier("InputProductType")
GraphQLInputType getInputProductType() {
    return newInputObject()
            .name("ProductDtoInput")
            .field(newInputObjectField()
                    .name("productId")
                    .type(GraphQLID))
            .field(newInputObjectField()
                    .name("name")
                    .type(GraphQLString))
            .field(newInputObjectField()
                    .name("brand")
                    .type(GraphQLString))
            .field(newInputObjectField()
                    .name("description")
                    .type(GraphQLString))
            .field(newInputObjectField()
                    .name("category")
                    .type(list(GraphQLString)))
            .field(newInputObjectField()
                    .name("price")
                    .type(GraphQLFloat))
            .build();
}
 
开发者ID:roybailey,项目名称:research-graphql,代码行数:26,代码来源:ManualGraphQLMutationSchema.java


示例2: buildInstanceInputType

import graphql.schema.GraphQLInputType; //导入依赖的package包/类
@Override
public GraphQLInputType buildInstanceInputType(InstanceFieldBuilderContext instanceFieldBuilderContext) {
    GraphQLInputObjectField idField = newInputObjectField()
            .type(new GraphQLNonNull(GraphQLID))
            .name(REFERENCE_ID)
            .build();

    GraphQLInputObjectField schemaInstanceKeyField = newInputObjectField()
            .type(new GraphQLNonNull(SchemaInstanceKey.buildSchemaInputType()))
            .name(SCHEMA_INSTANCE_KEY_FIELD)
            .build();

    return GraphQLInputObjectType.newInputObject()
            .name(getParent().getName() + getMemberFieldName() + "MultiTypeDynamicReference")
            .field(idField)
            .field(schemaInstanceKeyField)
            .build();
}
 
开发者ID:nfl,项目名称:gold,代码行数:19,代码来源:MultiTypeDynamicReferenceType.java


示例3: getGraphQLTypeForSearch

import graphql.schema.GraphQLInputType; //导入依赖的package包/类
public static GraphQLInputObjectType getGraphQLTypeForSearch(Class<?> clazz) { 
	List<GraphQLInputObjectField> fields = new LinkedList<GraphQLInputObjectField>();
	for (Method m : clazz.getMethods()) { 
		if (m.getName().startsWith("get")) { 
			if (m.isAnnotationPresent(GraphQLIgnore.class)) { continue; } 
			if (m.getName().equalsIgnoreCase("getClass")) { continue; } 
			String name = lowerCaseFirstLetter(m.getName().substring(3));
			fields.add(GraphQLInputObjectField.newInputObjectField()
				.name(name)
				.type((GraphQLInputType) getGraphQLTypeForJavaType(m.getGenericReturnType()))
				.build());
		}
	}
	
	return new GraphQLInputObjectType(clazz.getSimpleName(), "", fields);
}
 
开发者ID:deptofdefense,项目名称:anet,代码行数:17,代码来源:GraphQLUtils.java


示例4: getInputType

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


示例5: getListInputMapping

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


示例6: getArgument

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


示例7: getArgumentType

import graphql.schema.GraphQLInputType; //导入依赖的package包/类
@Override
public GraphQLInputType getArgumentType(ArgContainer container) {
    if (container == null) return null;
    Object object = container.getRepresentativeObject();
    if (object == null) return null;
    
    if (object instanceof ParameterizedType
            || object instanceof WildcardType
            || object instanceof TypeVariable) {
        return (GraphQLInputType) getContext().getParameterizedType(
                object,
                (Type) object,
                TypeKind.INPUT_OBJECT);
    }
    return getContext().getInputType(object);
}
 
开发者ID:graphql-java,项目名称:graphql-java-type-generator,代码行数:17,代码来源:ArgumentType_Reflection.java


示例8: getInputFieldDefinition

import graphql.schema.GraphQLInputType; //导入依赖的package包/类
/**
 * May return null should this field be disallowed
 * @param object
 * @return
 */
protected GraphQLInputObjectField.Builder getInputFieldDefinition(
        final Object object) {
    String fieldName = getFieldName(object);
    GraphQLInputType fieldType = (GraphQLInputType)
            getTypeOfField(object, TypeKind.INPUT_OBJECT);
    if (fieldName == null || fieldType == null) {
        return null;
    }
    String fieldDescription  = getFieldDescription(object);
    String fieldDefaultValue  = getFieldDefaultValue(object);
    logger.debug("GraphQL field will be of type [{}] and name [{}] with description [{}]",
            fieldType, fieldName, fieldDescription);
    
    GraphQLInputObjectField.Builder fieldBuilder = newInputObjectField()
            .name(fieldName)
            .type(fieldType)
            .description(fieldDescription)
            .defaultValue(fieldDefaultValue);
    return fieldBuilder;
}
 
开发者ID:graphql-java,项目名称:graphql-java-type-generator,代码行数:26,代码来源:FieldsGenerator.java


示例9: generateInputType

import graphql.schema.GraphQLInputType; //导入依赖的package包/类
protected GraphQLInputType generateInputType(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<GraphQLInputObjectField> fields = getInputFieldDefinitions(object);
    if (fields == null || fields.isEmpty()) {
        return null;
    }
    String typeName = getGraphQLTypeNameOrIdentityCode(object);
    
    GraphQLInputObjectType.Builder builder = new GraphQLInputObjectType.Builder();
    builder.name(typeName);
    builder.fields(fields);
    builder.description(getTypeDescription(object));
    return builder.build();
}
 
开发者ID:graphql-java,项目名称:graphql-java-type-generator,代码行数:21,代码来源:FullTypeGenerator.java


示例10: mapEntry

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

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


示例11: buildInputObjectArgument

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


示例12: getInputType

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


示例13: getInputType

import graphql.schema.GraphQLInputType; //导入依赖的package包/类
@Override
public GraphQLInputType getInputType(IGraphQLObjectMapper graphQLObjectMapper, Type type) {
	if (type instanceof ParameterizedType) {
		return getListInputMapping(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


示例14: getInputType

import graphql.schema.GraphQLInputType; //导入依赖的package包/类
@Override
public GraphQLInputType getInputType(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,代码行数:13,代码来源:EnumSetMapper.java


示例15: registerType

import graphql.schema.GraphQLInputType; //导入依赖的package包/类
@Override
public GraphQLType registerType(String typeName, GraphQLType graphQlType, TypeKind typeKind) {
    switch (typeKind) {
    case OBJECT:
    case INTERFACE:
        return registerType(typeName, (GraphQLOutputType) graphQlType);
    case INPUT_OBJECT:
        return registerType(typeName, (GraphQLInputType) graphQlType);
    default:
        return null;
    }
}
 
开发者ID:graphql-java,项目名称:graphql-java-type-generator,代码行数:13,代码来源:StaticTypeRepository.java


示例16: clear

import graphql.schema.GraphQLInputType; //导入依赖的package包/类
/**
 * Resets the internal data of the TypeRepository to empty
 */
public void clear() {
    //anyone working on the old types doesn't want to have
    //their generated*Types .clear()ed out from under them. 
    generatedOutputTypes =
            new ConcurrentHashMap<String, GraphQLOutputType>();
    generatedInputTypes =
            new ConcurrentHashMap<String, GraphQLInputType>();
}
 
开发者ID:graphql-java,项目名称:graphql-java-type-generator,代码行数:12,代码来源:StaticTypeRepository.java


示例17: graphQLInputType

import graphql.schema.GraphQLInputType; //导入依赖的package包/类
@Override
public GraphQLInputType graphQLInputType(AnnotatedType javaType, Set<Type> abstractTypes, OperationMapper operationMapper, BuildContext buildContext) {
    String typeName = getInputTypeName(javaType, buildContext);
    if (buildContext.knownInputTypes.contains(typeName)) {
        return new GraphQLTypeReference(typeName);
    }
    buildContext.knownInputTypes.add(typeName);
    return toGraphQLInputType(typeName, javaType, abstractTypes, operationMapper, buildContext);
}
 
开发者ID:leangen,项目名称:graphql-spqr,代码行数:10,代码来源:CachingMapper.java


示例18: getTypeName

import graphql.schema.GraphQLInputType; //导入依赖的package包/类
private String getTypeName(AnnotatedType javaType, AnnotatedType graphQLType, TypeInfoGenerator typeInfoGenerator) {
    if (GenericTypeReflector.isSuperType(GraphQLScalarType.class, graphQLType.getType())) {
        return typeInfoGenerator.generateScalarTypeName(javaType);
    }
    if (GenericTypeReflector.isSuperType(GraphQLInputType.class, graphQLType.getType())) {
        return typeInfoGenerator.generateInputTypeName(javaType);
    }
    return typeInfoGenerator.generateTypeName(javaType);
}
 
开发者ID:leangen,项目名称:graphql-spqr,代码行数:10,代码来源:CachingMapper.java


示例19: toGraphQLInputType

import graphql.schema.GraphQLInputType; //导入依赖的package包/类
@Override
public GraphQLInputType toGraphQLInputType(AnnotatedType javaType, Set<Type> abstractTypes, OperationMapper operationMapper, BuildContext buildContext) {
    return new GraphQLList(
            mapEntry(
                    operationMapper.toGraphQLInputType(getElementType(javaType, 0), abstractTypes, buildContext),
                    operationMapper.toGraphQLInputType(getElementType(javaType, 1), abstractTypes, buildContext), buildContext));
}
 
开发者ID:leangen,项目名称:graphql-spqr,代码行数:8,代码来源:MapToListTypeAdapter.java


示例20: BuildContext

import graphql.schema.GraphQLInputType; //导入依赖的package包/类
/**
 * The shared context accessible throughout the schema generation process
 *
 * @param operationRepository Repository that can be used to fetch all known (singleton and domain) queries
 * @param typeMappers Repository of all registered {@link io.leangen.graphql.generator.mapping.TypeMapper}s
 * @param environment The globally shared environment
 * @param interfaceStrategy The strategy deciding what Java type gets mapped to a GraphQL interface
 * @param basePackages The base (root) package of the entire project
 * @param typeInfoGenerator Generates type name/description
 * @param valueMapperFactory The factory used to produce {@link io.leangen.graphql.metadata.strategy.value.ValueMapper} instances
 * @param inputFieldStrategy The strategy deciding how GraphQL input fields are discovered from Java types
 * @param knownTypes The cache of known type names
 * @param relayMappingConfig Relay specific configuration
 */
public BuildContext(OperationRepository operationRepository, TypeMapperRepository typeMappers,
                    GlobalEnvironment environment,
                    InterfaceMappingStrategy interfaceStrategy, String[] basePackages,
                    TypeInfoGenerator typeInfoGenerator, ValueMapperFactory valueMapperFactory,
                    InputFieldDiscoveryStrategy inputFieldStrategy, Set<GraphQLType> knownTypes,
                    RelayMappingConfig relayMappingConfig) {
    this.operationRepository = operationRepository;
    this.typeRepository = environment.typeRepository;
    this.typeMappers = typeMappers;
    this.typeInfoGenerator = typeInfoGenerator;
    this.relay = environment.relay;
    this.node = knownTypes.stream()
            .filter(GraphQLUtils::isRelayNodeInterface)
            .findFirst().map(type -> (GraphQLInterfaceType) type)
            .orElse(relay.nodeInterface(new RelayNodeTypeResolver(this.typeRepository, typeInfoGenerator)));
    this.typeResolver = new DelegatingTypeResolver(this.typeRepository, typeInfoGenerator);
    this.interfaceStrategy = interfaceStrategy;
    this.basePackages = basePackages;
    this.valueMapperFactory = valueMapperFactory;
    this.inputFieldStrategy = inputFieldStrategy;
    this.globalEnvironment = environment;
    this.knownTypes = knownTypes.stream()
            .filter(type -> type instanceof GraphQLOutputType)
            .map(GraphQLType::getName)
            .collect(Collectors.toSet());
    this.knownInputTypes = knownTypes.stream()
            .filter(type -> type instanceof GraphQLInputType)
            .map(GraphQLType::getName)
            .collect(Collectors.toSet());
    this.relayMappingConfig = relayMappingConfig;
}
 
开发者ID:leangen,项目名称:graphql-spqr,代码行数:46,代码来源:BuildContext.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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