当前位置: 首页>>代码示例>>Java>>正文


Java GraphQLTypeReference类代码示例

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


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


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