本文整理汇总了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();
}
示例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;
}
示例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());
}
示例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();
}