private Builder(FieldDefinition existing) { this.sourceLocation = existing.getSourceLocation(); this.name = existing.getName(); this.comments = existing.getComments(); this.type = existing.getType(); this.description = existing.getDescription(); this.inputValueDefinitions = existing.getInputValueDefinitions(); this.directives = existing.getDirectives(); this.ignoredChars = existing.getIgnoredChars(); }
private FieldDefAndDirectiveParams buildField(BuildContext buildCtx, TypeDefinition parentType, FieldDefinition fieldDef) { buildCtx.enterNode(fieldDef); GraphQLFieldDefinition.Builder builder = GraphQLFieldDefinition.newFieldDefinition(); builder.definition(fieldDef); builder.name(fieldDef.getName()); builder.description(schemaGeneratorHelper.buildDescription(fieldDef, fieldDef.getDescription())); builder.deprecate(schemaGeneratorHelper.buildDeprecationReason(fieldDef.getDirectives())); GraphQLDirective[] directives = buildDirectives(fieldDef.getDirectives(), Collections.emptyList(), DirectiveLocation.FIELD_DEFINITION, buildCtx.getDirectiveDefinitions()); builder.withDirectives( directives ); fieldDef.getInputValueDefinitions().forEach(inputValueDefinition -> builder.argument(buildArgument(buildCtx, inputValueDefinition))); GraphQLOutputType fieldType = buildOutputType(buildCtx, fieldDef.getType()); builder.type(fieldType); GraphQLFieldDefinition fieldDefinition = builder.build(); // if they have already wired in a fetcher - then leave it alone FieldCoordinates coordinates = FieldCoordinates.coordinates(parentType.getName(), fieldDefinition.getName()); if (!buildCtx.codeRegistry.hasDataFetcher(coordinates)) { DataFetcherFactory dataFetcherFactory = buildDataFetcherFactory(buildCtx, parentType, fieldDef, fieldType, Arrays.asList(directives)); buildCtx.getCodeRegistry().dataFetcher(coordinates, dataFetcherFactory); } return buildCtx.exitNode(new FieldDefAndDirectiveParams(fieldDefinition, buildCtx.mkBehaviourParams())); }
} else if (descriptionHolder instanceof GraphQLFieldDefinition) { GraphQLFieldDefinition type = (GraphQLFieldDefinition) descriptionHolder; return descriptionAndComments(type::getDescription, type::getDefinition, () -> type.getDefinition().getDescription()); } else if (descriptionHolder instanceof GraphQLEnumValueDefinition) { GraphQLEnumValueDefinition type = (GraphQLEnumValueDefinition) descriptionHolder;
private Builder(FieldDefinition existing) { this.sourceLocation = existing.getSourceLocation(); this.name = existing.getName(); this.comments = existing.getComments(); this.type = existing.getType(); this.description = existing.getDescription(); this.inputValueDefinitions = existing.getInputValueDefinitions(); this.directives = existing.getDirectives(); this.ignoredChars = existing.getIgnoredChars(); }
private FieldDefAndDirectiveParams buildField(BuildContext buildCtx, TypeDefinition parentType, FieldDefinition fieldDef) { buildCtx.enterNode(fieldDef); GraphQLFieldDefinition.Builder builder = GraphQLFieldDefinition.newFieldDefinition(); builder.definition(fieldDef); builder.name(fieldDef.getName()); builder.description(schemaGeneratorHelper.buildDescription(fieldDef, fieldDef.getDescription())); builder.deprecate(schemaGeneratorHelper.buildDeprecationReason(fieldDef.getDirectives())); GraphQLDirective[] directives = buildDirectives(fieldDef.getDirectives(), Collections.emptyList(), DirectiveLocation.FIELD_DEFINITION, buildCtx.getDirectiveDefinitions()); builder.withDirectives( directives ); fieldDef.getInputValueDefinitions().forEach(inputValueDefinition -> builder.argument(buildArgument(buildCtx, inputValueDefinition))); GraphQLOutputType fieldType = buildOutputType(buildCtx, fieldDef.getType()); builder.type(fieldType); GraphQLFieldDefinition fieldDefinition = builder.build(); // if they have already wired in a fetcher - then leave it alone FieldCoordinates coordinates = FieldCoordinates.coordinates(parentType.getName(), fieldDefinition.getName()); if (!buildCtx.codeRegistry.hasDataFetcher(coordinates)) { DataFetcherFactory dataFetcherFactory = buildDataFetcherFactory(buildCtx, parentType, fieldDef, fieldType, Arrays.asList(directives)); buildCtx.getCodeRegistry().dataFetcher(coordinates, dataFetcherFactory); } return buildCtx.exitNode(new FieldDefAndDirectiveParams(fieldDefinition, buildCtx.mkBehaviourParams())); }
} else if (descriptionHolder instanceof GraphQLFieldDefinition) { GraphQLFieldDefinition type = (GraphQLFieldDefinition) descriptionHolder; return descriptionAndComments(type::getDescription, type::getDefinition, () -> type.getDefinition().getDescription()); } else if (descriptionHolder instanceof GraphQLEnumValueDefinition) { GraphQLEnumValueDefinition type = (GraphQLEnumValueDefinition) descriptionHolder;