use of graphql.schema.GraphQLEnumValueDefinition in project graphql-java by graphql-java.
the class SchemaGenerator method buildEnumType.
private GraphQLEnumType buildEnumType(BuildContext buildCtx, EnumTypeDefinition typeDefinition) {
GraphQLEnumType.Builder builder = GraphQLEnumType.newEnum();
builder.definition(typeDefinition);
builder.name(typeDefinition.getName());
builder.description(schemaGeneratorHelper.buildDescription(typeDefinition, typeDefinition.getDescription()));
List<EnumTypeExtensionDefinition> extensions = enumTypeExtensions(typeDefinition, buildCtx);
EnumValuesProvider enumValuesProvider = buildCtx.getWiring().getEnumValuesProviders().get(typeDefinition.getName());
typeDefinition.getEnumValueDefinitions().forEach(evd -> {
GraphQLEnumValueDefinition enumValueDefinition = buildEnumValue(buildCtx, typeDefinition, enumValuesProvider, evd);
builder.value(enumValueDefinition);
});
extensions.forEach(extension -> extension.getEnumValueDefinitions().forEach(evd -> {
GraphQLEnumValueDefinition enumValueDefinition = buildEnumValue(buildCtx, typeDefinition, enumValuesProvider, evd);
if (!builder.hasValue(enumValueDefinition.getName())) {
builder.value(enumValueDefinition);
}
}));
builder.withDirectives(buildDirectives(typeDefinition.getDirectives(), directivesOf(extensions), ENUM));
return builder.build();
}
Aggregations