private void buildObjectTypeInterfaces(BuildContext buildCtx, ObjectTypeDefinition typeDefinition, GraphQLObjectType.Builder builder, List<ObjectTypeExtensionDefinition> extensions) { Map<String, GraphQLOutputType> interfaces = new LinkedHashMap<>(); typeDefinition.getImplements().forEach(type -> { GraphQLOutputType newInterfaceType = buildOutputType(buildCtx, type); interfaces.put(newInterfaceType.getName(), newInterfaceType); }); extensions.forEach(extension -> extension.getImplements().forEach(type -> { GraphQLInterfaceType interfaceType = buildOutputType(buildCtx, type); if (!interfaces.containsKey(interfaceType.getName())) { interfaces.put(interfaceType.getName(), interfaceType); } })); interfaces.values().forEach(interfaze -> { if (interfaze instanceof GraphQLInterfaceType) { builder.withInterface((GraphQLInterfaceType) interfaze); return; } if (interfaze instanceof GraphQLTypeReference) { builder.withInterface((GraphQLTypeReference) interfaze); return; } }); }
.withInterface(nodeInterface) .field(GraphQLFieldDefinition.newFieldDefinition() .name("id") .withInterface(nodeInterface) .field(GraphQLFieldDefinition.newFieldDefinition() .name("id") .withInterface(nodeInterface) .field(GraphQLFieldDefinition.newFieldDefinition() .name("id") .withInterface(nodeInterface) .field(GraphQLFieldDefinition.newFieldDefinition() .name("id") .withInterface(nodeInterface) .field(GraphQLFieldDefinition.newFieldDefinition() .name("id") .name("Agency") .description("Agency in the graph") .withInterface(nodeInterface) .field(GraphQLFieldDefinition.newFieldDefinition() .name("id")
private void buildObjectTypeInterfaces(BuildContext buildCtx, ObjectTypeDefinition typeDefinition, GraphQLObjectType.Builder builder, List<ObjectTypeExtensionDefinition> extensions) { Map<String, GraphQLOutputType> interfaces = new LinkedHashMap<>(); typeDefinition.getImplements().forEach(type -> { GraphQLOutputType newInterfaceType = buildOutputType(buildCtx, type); interfaces.put(newInterfaceType.getName(), newInterfaceType); }); extensions.forEach(extension -> extension.getImplements().forEach(type -> { GraphQLInterfaceType interfaceType = buildOutputType(buildCtx, type); if (!interfaces.containsKey(interfaceType.getName())) { interfaces.put(interfaceType.getName(), interfaceType); } })); interfaces.values().forEach(interfaze -> { if (interfaze instanceof GraphQLInterfaceType) { builder.withInterface((GraphQLInterfaceType) interfaze); return; } if (interfaze instanceof GraphQLTypeReference) { builder.withInterface((GraphQLTypeReference) interfaze); return; } }); }
return newObject() .name(BRANCH) .withInterface(projectEntityInterface.getTypeRef()) .fields(projectEntityInterfaceFields()) .field(GraphqlUtils.disabledField())
glType.withInterface((GraphQLInterfaceType) getOutputTypeCache().get(nodeTypeName));
String ifaceName = graphQLObjectInfoRetriever.getTypeName(iface); if (container.getProcessing().contains(ifaceName)) { builder.withInterface(new GraphQLTypeReference(ifaceName)); } else { builder.withInterface((GraphQLInterfaceType) graphQLInterfaceRetriever.getInterface(iface, container));
return newObject() .name(PROMOTION_LEVEL) .withInterface(projectEntityInterface.getTypeRef()) .fields(projectEntityInterfaceFields())
builder.withInterface((GraphQLInterfaceType) getInterface(iface));
@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(); }
private void createTodoType() { todoType = newObject() .name("Todo") .field(newFieldDefinition() .name("id") .type(new GraphQLNonNull(GraphQLID)) .dataFetcher(environment -> { Todo todo = (Todo) environment.getSource(); return relay.toGlobalId("Todo", todo.getId()); } ) .build()) .field(newFieldDefinition() .name("text") .type(Scalars.GraphQLString) .build()) .field(newFieldDefinition() .name("complete") .type(Scalars.GraphQLBoolean) .build()) .withInterface(nodeInterface) .build(); }
@Override public GraphQLObjectType toGraphQLType(String typeName, AnnotatedType javaType, OperationMapper operationMapper, BuildContext buildContext) { GraphQLObjectType.Builder typeBuilder = newObject() .name(typeName) .description(buildContext.typeInfoGenerator.generateTypeDescription(javaType, buildContext.messageBundle)); List<GraphQLFieldDefinition> fields = getFields(javaType, buildContext, operationMapper); fields.forEach(typeBuilder::field); List<GraphQLOutputType> interfaces = getInterfaces(javaType, fields, buildContext, operationMapper); interfaces.forEach(inter -> { if (inter instanceof GraphQLInterfaceType) { typeBuilder.withInterface((GraphQLInterfaceType) inter); } else { typeBuilder.withInterface((GraphQLTypeReference) inter); } }); typeBuilder.withDirective(Directives.mappedType(javaType)); buildContext.directiveBuilder.buildObjectTypeDirectives(javaType, buildContext.directiveBuilderParams()).forEach(directive -> typeBuilder.withDirective(operationMapper.toGraphQLDirective(directive, buildContext))); GraphQLObjectType type = typeBuilder.build(); interfaces.forEach(inter -> buildContext.typeRegistry.registerCovariantType(inter.getName(), javaType, type)); return type; }
private void createUserType() { userType = newObject() .name("User") .field(newFieldDefinition() .name("id") .type(new GraphQLNonNull(GraphQLID)) .dataFetcher(environment -> { User user = (User) environment.getSource(); return relay.toGlobalId("User", user.getId()); } ) .build()) .field(newFieldDefinition() .name("todos") .type(connectionFromUserToTodos) .argument(relay.getConnectionFieldArguments()) .dataFetcher(simpleConnection) .build()) .withInterface(nodeInterface) .build(); }
public static GraphQLObjectType.Builder elementTypeBuilder () { return objectTypeBuilder().withInterface(IElement.REF) .field(Fields.notNullStringField("id")); }
public Builder withInterfaces(GraphQLTypeReference... references) { for (GraphQLTypeReference reference : references) { withInterface(reference); } return this; }
public Builder withInterfaces(GraphQLInterfaceType... interfaceType) { for (GraphQLInterfaceType type : interfaceType) { withInterface(type); } return this; }
.withInterface(typeRef("InterfaceType")) .field(newFieldDefinition() .name("value")
public Builder withInterfaces(GraphQLInterfaceType... interfaceType) { for (GraphQLInterfaceType type : interfaceType) { withInterface(type); } return this; }
public Builder withInterfaces(GraphQLTypeReference... references) { for (GraphQLTypeReference reference : references) { withInterface(reference); } return this; }