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

Java GraphQLTypeReference类代码示例

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

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



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

示例1: toGraphQLType

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


示例2: mapEntry

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


示例3: replaceTypeReferences

import graphql.schema.GraphQLTypeReference; //导入依赖的package包/类
public void replaceTypeReferences() {
    for (Map<String, MappedType> covariantTypes : this.covariantOutputTypes.values()) {
        Set<String> toRemove = new HashSet<>();
        for (Map.Entry<String, MappedType> entry : covariantTypes.entrySet()) {
            if (entry.getValue().graphQLType instanceof GraphQLTypeReference) {
                GraphQLObjectType resolvedType = knownObjectTypes.get(entry.getKey());
                if (resolvedType != null) {
                    entry.setValue(new MappedType(entry.getValue().javaType, resolvedType));
                } else {
                    log.warn("Type reference " + entry.getKey() + " could not be replaced correctly. " +
                            "This can occur when the schema generator is initialized with " +
                            "additional types not built by GraphQL-SPQR. If this type implements " +
                            "Node, in some edge cases it may end up not exposed via the 'node' query.");
                    //the edge case is when the primary resolver returns an interface or a union and not the node type directly
                    toRemove.add(entry.getKey());
                }
            }
        }
        toRemove.forEach(covariantTypes::remove);
        covariantTypes.replaceAll((typeName, mapped) -> mapped.graphQLType instanceof GraphQLTypeReference
                ? new MappedType(mapped.javaType, knownObjectTypes.get(typeName)) : mapped);
    }
    knownObjectTypes.clear();
}
 
开发者ID:leangen,项目名称:graphql-spqr,代码行数:25,代码来源:TypeRepository.java


示例4: newPagingSearchField

import graphql.schema.GraphQLTypeReference; //导入依赖的package包/类
/**
 * Construct a field which can page the result set and also accept a elasticsearch query for processing.
 * 
 * @param name
 *            Name of the field
 * @param description
 *            Description of the field
 * @param rootProvider
 *            Provider of the root element (will only be used when no query was specified)
 * @param pageTypeName
 *            Name of the page type
 * @param indexHandler
 *            Handler which will be used to invoke the query
 * @return
 */
protected GraphQLFieldDefinition newPagingSearchField(String name, String description, Function<GraphQLContext, RootVertex<?>> rootProvider,
		String pageTypeName, SearchHandler searchHandler) {
	return newFieldDefinition().name(name).description(description).argument(createPagingArgs()).argument(createQueryArg()).type(
			new GraphQLTypeReference(pageTypeName)).dataFetcher((env) -> {
				GraphQLContext gc = env.getContext();
				String query = env.getArgument("query");
				if (query != null) {
					try {
						return searchHandler.query(gc, query, getPagingInfo(env), READ_PERM);
					} catch (MeshConfigurationException | InterruptedException | ExecutionException | TimeoutException e) {
						throw new RuntimeException(e);
					}
				} else {
					return rootProvider.apply(gc).findAll(gc, getPagingInfo(env));
				}
			}).build();
}
 
开发者ID:gentics,项目名称:mesh,代码行数:33,代码来源:AbstractTypeProvider.java


示例5: getElementTypeOfList

import graphql.schema.GraphQLTypeReference; //导入依赖的package包/类
private GraphQLType getElementTypeOfList(ListFieldSchema schema) {
	switch (schema.getListType()) {
	case "boolean":
		return GraphQLBoolean;
	case "html":
		return GraphQLString;
	case "string":
		return GraphQLString;
	case "number":
		return GraphQLBigDecimal;
	case "date":
		return GraphQLString;
	case "node":
		return new GraphQLTypeReference("Node");
	case "micronode":
		return new GraphQLTypeReference("Micronode");
	default:
		return null;
	}
}
 
开发者ID:gentics,项目名称:mesh,代码行数:21,代码来源:FieldDefinitionProvider.java


示例6: createNodeDef

import graphql.schema.GraphQLTypeReference; //导入依赖的package包/类
/**
 * Generate a new node field definition using the provided field schema.
 * 
 * @param schema
 * @return
 */
public GraphQLFieldDefinition createNodeDef(FieldSchema schema) {
	return newFieldDefinition().name(schema.getName()).argument(createLanguageTagArg()).description(schema.getLabel())
			.type(new GraphQLTypeReference(NODE_TYPE_NAME)).dataFetcher(env -> {
				GraphQLContext gc = env.getContext();
				GraphFieldContainer source = env.getSource();
				// TODO decide whether we want to reference the default content by default
				NodeGraphField nodeField = source.getNode(schema.getName());
				if (nodeField != null) {
					Node node = nodeField.getNode();
					if (node != null) {
						// TODO the language should be loaded using the parent node language. Note that we would need to check for micronodes which are not
						// language specific!
						List<String> languageTags = getLanguageArgument(env);
						// Check permissions for the linked node
						gc.requiresPerm(node, READ_PERM, READ_PUBLISHED_PERM);
						NodeGraphFieldContainer container = node.findVersion(gc, languageTags);
						return new NodeContent(node, container);
					}
				}
				return null;
			}).build();
}
 
开发者ID:gentics,项目名称:mesh,代码行数:29,代码来源:FieldDefinitionProvider.java


示例7: createType

import graphql.schema.GraphQLTypeReference; //导入依赖的package包/类
public GraphQLObjectType createType() {
	Builder releaseType = newObject().name(RELEASE_TYPE_NAME);
	interfaceTypeProvider.addCommonFields(releaseType);

	// .name
	releaseType.field(newFieldDefinition().name("name").type(GraphQLString));

	// .migrated
	releaseType.field(newFieldDefinition().name("migrated").type(GraphQLBoolean));

	// .schema
	releaseType.field(
		newFieldDefinition().name("schema").description("Load schema by name or uuid.")
			.argument(createUuidArg("Uuid of the schema."))
			.argument(createNameArg("Name of the schema."))
			.type(new GraphQLTypeReference(SCHEMA_TYPE_NAME))
			.dataFetcher(this::handleReleaseSchema)
			.build()
	);

	// .schemas
	releaseType.field(newPagingFieldWithFetcher("schemas", "Load schemas assigned to this release.",
			this::handleReleaseSchemas, SCHEMA_PAGE_TYPE_NAME));

	return releaseType.build();
}
 
开发者ID:gentics,项目名称:mesh,代码行数:27,代码来源:ReleaseTypeProvider.java


示例8: createType

import graphql.schema.GraphQLTypeReference; //导入依赖的package包/类
@Override
public GraphQLObjectType createType(GQLTypeCache cache) {
    return newObject()
            .name(GLOBAL_ROLE)
            .field(GraphqlUtils.stringField("id", "ID of the role"))
            .field(GraphqlUtils.nameField("Unique name for the role"))
            .field(GraphqlUtils.stringField("description", "Description of the role"))
            // List of groups
            .field(f -> f.name("groups")
                    .description("List of groups having this role")
                    .type(stdList(new GraphQLTypeReference(GQLTypeAccountGroup.ACCOUNT_GROUP)))
                    .dataFetcher(fetcher(GlobalRole.class, accountService::findAccountGroupsByGlobalRole))
            )
            // List of accounts
            .field(f -> f.name("accounts")
                    .description("List of accounts having this role")
                    .type(stdList(new GraphQLTypeReference(GQLTypeAccount.ACCOUNT)))
                    .dataFetcher(fetcher(GlobalRole.class, accountService::findAccountsByGlobalRole))
            )
            // OK
            .build();
}
 
开发者ID:nemerosa,项目名称:ontrack,代码行数:23,代码来源:GQLTypeGlobalRole.java


示例9: createType

import graphql.schema.GraphQLTypeReference; //导入依赖的package包/类
@Override
public GraphQLObjectType createType(GQLTypeCache cache) {
    return newObject()
            .name(AUTHORIZED_PROJECT)
            .field(
                    newFieldDefinition()
                            .name("role")
                            .description("Role for the project")
                            .type(new GraphQLNonNull(projectRole.getTypeRef()))
                            .dataFetcher(fetcher(ProjectRoleAssociation.class, ProjectRoleAssociation::getProjectRole))
                            .build()
            )
            .field(
                    newFieldDefinition()
                            .name("project")
                            .description("Authorized project")
                            .type(new GraphQLNonNull(new GraphQLTypeReference(GQLTypeProject.PROJECT)))
                            .dataFetcher(fetcher(
                                    ProjectRoleAssociation.class,
                                    pra -> structureService.getProject(ID.of(pra.getProjectId()))
                            ))
                            .build()
            )
            .build();
}
 
开发者ID:nemerosa,项目名称:ontrack,代码行数:26,代码来源:GQLTypeAuthorizedProject.java


示例10: createType

import graphql.schema.GraphQLTypeReference; //导入依赖的package包/类
@Override
public GraphQLObjectType createType(GQLTypeCache cache) {
    return newObject()
            .name(PROMOTION_RUN)
            .withInterface(projectEntityInterface.getTypeRef())
            .fields(projectEntityInterfaceFields())
            .field(
                    newFieldDefinition()
                            .name("build")
                            .description("Associated build")
                            .type(new GraphQLNonNull(new GraphQLTypeReference(GQLTypeBuild.BUILD)))
                            .build()
            )
            // Promotion level
            .field(
                    newFieldDefinition()
                            .name("promotionLevel")
                            .description("Associated promotion level")
                            .type(new GraphQLNonNull(new GraphQLTypeReference(GQLTypePromotionLevel.PROMOTION_LEVEL)))
                            .build()
            )
            // OK
            .build();
}
 
开发者ID:nemerosa,项目名称:ontrack,代码行数:25,代码来源:GQLTypePromotionRun.java


示例11: createType

import graphql.schema.GraphQLTypeReference; //导入依赖的package包/类
@Override
public GraphQLObjectType createType(GQLTypeCache cache) {
    return newObject()
            .name(PROJECT_AUTHORIZATION)
            .field(GraphqlUtils.stringField("id", "ID of the role"))
            .field(GraphqlUtils.nameField("Unique name for the role"))
            .field(GraphqlUtils.stringField("description", "Description of the role"))
            // List of groups
            .field(f -> f.name("groups")
                    .description("List of groups having this role")
                    .type(stdList(new GraphQLTypeReference(GQLTypeAccountGroup.ACCOUNT_GROUP)))
            )
            // List of accounts
            .field(f -> f.name("accounts")
                    .description("List of accounts having this role")
                    .type(stdList(new GraphQLTypeReference(GQLTypeAccount.ACCOUNT)))
            )
            // OK
            .build();
}
 
开发者ID:nemerosa,项目名称:ontrack,代码行数:21,代码来源:GQLTypeProjectAuthorization.java


示例12: registerWorkspaceTypes

import graphql.schema.GraphQLTypeReference; //导入依赖的package包/类
private void registerWorkspaceTypes(Map<FacetRecord, FacetFields> resolved,
                                    PhantasmProcessor processor) throws NoSuchMethodException,
                                                                 InstantiationException,
                                                                 IllegalAccessException {
    registerBaseTypes(resolved, processor);

    processor.registerType(new ZtypeFunction(CoreUser.class,
                                             new GraphQLTypeReference(CoreUser.class.getSimpleName())));
    processor.registerType(new ZtypeFunction(Classification.class,
                                             new GraphQLTypeReference(Classification.class.getSimpleName())));
    processor.registerType(new ZtypeFunction(CoreInstance.class,
                                             new GraphQLTypeReference(CoreInstance.class.getSimpleName())));
    processor.registerType(new ZtypeFunction(Permission.class,
                                             new GraphQLTypeReference(Permission.class.getSimpleName())));
    processor.registerType(new ZtypeFunction(Role.class,
                                             new GraphQLTypeReference(Role.class.getSimpleName())));
    processor.registerType(new ZtypeFunction(ThisCoreInstance.class,
                                             new GraphQLTypeReference(ThisCoreInstance.class.getSimpleName())));
    processor.registerType(new ZtypeFunction(Workspace.class,
                                             new GraphQLTypeReference(Workspace.class.getSimpleName())));

    existentialType(resolved, processor);
}
 
开发者ID:ChiralBehaviors,项目名称:Ultrastructure,代码行数:24,代码来源:WorkspaceSchema.java


示例13: addPhantasmCast

import graphql.schema.GraphQLTypeReference; //导入依赖的package包/类
private void addPhantasmCast(GraphQLObjectType.Builder typeBuilder,
                             Entry<FacetRecord, FacetFields> resolved) {
    typeBuilder.field(GraphQLFieldDefinition.newFieldDefinition()
                                            .name(String.format("as%s",
                                                                WorkspacePresentation.toTypeName(resolved.getKey()
                                                                                                         .getName())))
                                            .description(String.format("Cast to the %s facet",
                                                                       resolved.getKey()
                                                                               .getName()))
                                            .type(new GraphQLTypeReference(resolved.getValue()
                                                                                   .getName()))
                                            .dataFetcher(env -> {
                                                Existential existential = (Existential) env.getSource();
                                                PhantasmCRUD crud = FacetFields.ctx(env);
                                                crud.cast(existential.getRecord(),
                                                          new Aspect(crud.getModel()
                                                                         .create(),
                                                                     resolved.getKey()));
                                                return existential;
                                            })
                                            .build());
}
 
开发者ID:ChiralBehaviors,项目名称:Ultrastructure,代码行数:23,代码来源:WorkspaceSchema.java


示例14: getFieldType

import graphql.schema.GraphQLTypeReference; //导入依赖的package包/类
private GraphQLType getFieldType(FieldDescriptor field) {
  if (field.getType() == FieldDescriptor.Type.MESSAGE
      || field.getType() == FieldDescriptor.Type.GROUP) {
    return new GraphQLTypeReference(getReferenceName(field.getMessageType()));
  }
  if (field.getType() == FieldDescriptor.Type.ENUM) {
    return new GraphQLTypeReference(ProtoToGql.getReferenceName(field.getEnumType()));
  }
  GraphQLType type = ProtoToGql.convertType(field);
  if (type instanceof GraphQLList) {
    return ((GraphQLList) type).getWrappedType();
  }
  return type;
}
 
开发者ID:google,项目名称:rejoiner,代码行数:15,代码来源:GqlInputConverter.java


示例15: graphQLType

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


示例16: graphQLInputType

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


示例17: toGraphQLType

import graphql.schema.GraphQLTypeReference; //导入依赖的package包/类
@Override
public GraphQLOutputType toGraphQLType(AnnotatedType javaType, Set<Type> abstractTypes, OperationMapper operationMapper, BuildContext buildContext) {
    AnnotatedType elementType = GenericTypeReflector.getTypeParameter(javaType, Page.class.getTypeParameters()[0]);
    String connectionName = buildContext.typeInfoGenerator.generateTypeName(elementType) + "Connection";
    if (buildContext.knownTypes.contains(connectionName)) {
        return new GraphQLTypeReference(connectionName);
    }
    buildContext.knownTypes.add(connectionName);
    GraphQLOutputType type = operationMapper.toGraphQLType(elementType, abstractTypes, buildContext);
    GraphQLObjectType edge = buildContext.relay.edgeType(type.getName(), type, null, Collections.emptyList());
    return buildContext.relay.connectionType(type.getName(), edge, Collections.emptyList());
}
 
开发者ID:leangen,项目名称:graphql-spqr,代码行数:13,代码来源:PageMapper.java


示例18: toGraphQLUnion

import graphql.schema.GraphQLTypeReference; //导入依赖的package包/类
@SuppressWarnings("WeakerAccess")
protected GraphQLOutputType toGraphQLUnion(String name, String description, AnnotatedType javaType, List<AnnotatedType> possibleJavaTypes,
                                           Set<Type> abstractTypes, OperationMapper operationMapper, BuildContext buildContext) {

    if (buildContext.knownTypes.contains(name)) {
        return new GraphQLTypeReference(name);
    }
    buildContext.knownTypes.add(name);
    GraphQLUnionType.Builder builder = newUnionType()
            .name(name)
            .description(description)
            .typeResolver(buildContext.typeResolver);

    possibleJavaTypes.stream()
            .map(pos -> operationMapper.toGraphQLType(pos, abstractTypes, buildContext))
            .forEach(type -> {
                if (type instanceof GraphQLObjectType) {
                    builder.possibleType((GraphQLObjectType) type);
                } else if (type instanceof GraphQLTypeReference) {
                    builder.possibleType((GraphQLTypeReference) type);
                } else {
                    throw new TypeMappingException(type.getClass().getSimpleName() +
                            " is not a valid GraphQL union member. Only object types can be unionized.");
                }
            });

    GraphQLUnionType union = new MappedGraphQLUnionType(builder.build(), javaType);
    for (int i = 0; i < possibleJavaTypes.size(); i++) {
        buildContext.typeRepository.registerCovariantType(union.getName(), possibleJavaTypes.get(i), union.getTypes().get(i));
    }
    return union;
}
 
开发者ID:leangen,项目名称:graphql-spqr,代码行数:33,代码来源:UnionMapper.java


示例19: registerCovariantType

import graphql.schema.GraphQLTypeReference; //导入依赖的package包/类
public void registerCovariantType(String compositeTypeName, AnnotatedType javaSubType, GraphQLOutputType subType) {
    this.covariantOutputTypes.putIfAbsent(compositeTypeName, new ConcurrentHashMap<>());
    Map<String, MappedType> covariantTypes = this.covariantOutputTypes.get(compositeTypeName);
    //never overwrite an exact type with a reference
    if (subType instanceof GraphQLObjectType || covariantTypes.get(subType.getName()) == null || covariantTypes.get(subType.getName()).graphQLType instanceof GraphQLTypeReference) {
        covariantTypes.put(subType.getName(), new MappedType(javaSubType, subType));
    }
}
 
开发者ID:leangen,项目名称:graphql-spqr,代码行数:9,代码来源:TypeRepository.java


示例20: replaceTypeReferencesForUnionType

import graphql.schema.GraphQLTypeReference; //导入依赖的package包/类
public static void replaceTypeReferencesForUnionType(final GraphQLSchema schema, final Set<GraphQLUnionType> graphQLUnionTypeMap) {
    Field graphQLTypesField = ReflectionUtils.findField(GraphQLUnionType.class, "types");
    graphQLTypesField.setAccessible(true);
    for (GraphQLUnionType graphQLUnionType : graphQLUnionTypeMap) {
        List<GraphQLType> graphQLTypes = new ArrayList<>();
        for (GraphQLType graphQLType : graphQLUnionType.getTypes()) {
            if (graphQLType instanceof GraphQLTypeReference) {
                graphQLTypes.add(schema.getType(graphQLType.getName()));
            } else {
                graphQLTypes.add(graphQLType);
            }
        }
        ReflectionUtils.setField(graphQLTypesField, graphQLUnionType, graphQLTypes);
    }
}
 
开发者ID:oembedler,项目名称:spring-graphql-common,代码行数:16,代码来源:SchemaHelper.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java ConfigurationTypeUtil类代码示例发布时间:2022-05-21
下一篇:
Java WorkspaceUndoUtil类代码示例发布时间: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