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


Java GraphQLInterfaceType.Builder方法代码示例

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


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

示例1: generateInterfaceType

import graphql.schema.GraphQLInterfaceType; //导入方法依赖的package包/类
protected GraphQLInterfaceType generateInterfaceType(Object object) {
    List<GraphQLFieldDefinition> fieldDefinitions = getOutputFieldDefinitions(object);
    if (fieldDefinitions == null || fieldDefinitions.isEmpty()) {
        return null;
    }
    String name = getGraphQLTypeNameOrIdentityCode(object);
    TypeResolver typeResolver = getTypeResolver(object);
    String description = getTypeDescription(object);
    if (name == null || fieldDefinitions == null || typeResolver == null) {
        return null;
    }
    GraphQLInterfaceType.Builder builder = GraphQLInterfaceType.newInterface()
            .description(description)
            .fields(fieldDefinitions)
            .name(name)
            .typeResolver(typeResolver);
    return builder.build();
}
 
开发者ID:graphql-java,项目名称:graphql-java-type-generator,代码行数:19,代码来源:FullTypeGenerator.java

示例2: toGraphQLType

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

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

    typeBuilder.typeResolver(buildContext.typeResolver);
    GraphQLInterfaceType type = new MappedGraphQLInterfaceType(typeBuilder.build(), javaType);

    if (javaType.isAnnotationPresent(GraphQLInterface.class)) {
        GraphQLInterface meta = javaType.getAnnotation(GraphQLInterface.class);
        if (meta.implementationAutoDiscovery()) {
            String[] scanPackages = meta.scanPackages();
            if (scanPackages.length == 0 && Utils.arrayNotEmpty(buildContext.basePackages)) {
                scanPackages = buildContext.basePackages;
            }
            ClassUtils.findImplementations(javaType, scanPackages).forEach(impl ->
                    getImplementingType(impl, abstractTypes, operationMapper, buildContext)
                            .ifPresent(implType -> buildContext.typeRepository.registerDiscoveredCovariantType(type.getName(), impl, implType)));

        }
    }
    return type;
}
 
开发者ID:leangen,项目名称:graphql-spqr,代码行数:30,代码来源:InterfaceMapper.java

示例3: addPhantasmCast

import graphql.schema.GraphQLInterfaceType; //导入方法依赖的package包/类
private void addPhantasmCast(GraphQLInterfaceType.Builder builder,
                             Entry<FacetRecord, FacetFields> resolved) {
    builder.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()))
                                        .build());
}
 
开发者ID:ChiralBehaviors,项目名称:Ultrastructure,代码行数:14,代码来源:WorkspaceSchema.java

示例4: existentialType

import graphql.schema.GraphQLInterfaceType; //导入方法依赖的package包/类
private GraphQLInterfaceType existentialType(Map<FacetRecord, FacetFields> resolved,
                                             PhantasmProcessor processor) {
    GraphQLInterfaceType.Builder builder = GraphQLInterfaceType.newInterface();
    builder.name("Existential")
           .description("The Existential interface type")
           .field(GraphQLFieldDefinition.newFieldDefinition()
                                        .name("id")
                                        .description("Existential id")
                                        .type(GraphQLUuid)
                                        .build())
           .field(GraphQLFieldDefinition.newFieldDefinition()
                                        .name("name")
                                        .description("Existential name")
                                        .type(GraphQLString)
                                        .build())
           .field(GraphQLFieldDefinition.newFieldDefinition()
                                        .name("description")
                                        .description("Existential description")
                                        .type(GraphQLString)
                                        .build())
           .field(GraphQLFieldDefinition.newFieldDefinition()
                                        .name("updatedBy")
                                        .description("Agency that updated the Existential")
                                        .type(new GraphQLTypeReference("Agency"))
                                        .build())
           .typeResolver(processor);

    resolved.entrySet()
            .forEach(e -> addPhantasmCast(builder, e));
    return builder.build();
}
 
开发者ID:ChiralBehaviors,项目名称:Ultrastructure,代码行数:32,代码来源:WorkspaceSchema.java


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