Search in sources :

Example 1 with GraphQLEnumValueDefinition

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();
}
Also used : Arrays(java.util.Arrays) Value(graphql.language.Value) INPUT_FIELD_DEFINITION(graphql.introspection.Introspection.DirectiveLocation.INPUT_FIELD_DEFINITION) GraphQLInputObjectType(graphql.schema.GraphQLInputObjectType) GraphQLFieldDefinition(graphql.schema.GraphQLFieldDefinition) GraphQLInterfaceType(graphql.schema.GraphQLInterfaceType) InputValueDefinition(graphql.language.InputValueDefinition) GraphQLInputObjectField(graphql.schema.GraphQLInputObjectField) GraphQLUnionType(graphql.schema.GraphQLUnionType) SchemaDefinition(graphql.language.SchemaDefinition) GraphQLEnumValueDefinition(graphql.schema.GraphQLEnumValueDefinition) UNION(graphql.introspection.Introspection.DirectiveLocation.UNION) EnumTypeDefinition(graphql.language.EnumTypeDefinition) Type(graphql.language.Type) INPUT_OBJECT(graphql.introspection.Introspection.DirectiveLocation.INPUT_OBJECT) TypeResolverProxy(graphql.schema.TypeResolverProxy) GraphQLEnumValueDefinition.newEnumValueDefinition(graphql.schema.GraphQLEnumValueDefinition.newEnumValueDefinition) DataFetcherFactory(graphql.schema.DataFetcherFactory) EnumValueDefinition(graphql.language.EnumValueDefinition) ObjectTypeExtensionDefinition(graphql.language.ObjectTypeExtensionDefinition) OBJECT(graphql.introspection.Introspection.DirectiveLocation.OBJECT) GraphQLError(graphql.GraphQLError) Map(java.util.Map) TypeName(graphql.language.TypeName) TypeResolver(graphql.schema.TypeResolver) OperationTypeDefinition(graphql.language.OperationTypeDefinition) GraphQLObjectType(graphql.schema.GraphQLObjectType) GraphQLDirective(graphql.schema.GraphQLDirective) NotAnInputTypeError(graphql.schema.idl.errors.NotAnInputTypeError) ObjectTypeDefinition(graphql.language.ObjectTypeDefinition) UnionTypeExtensionDefinition(graphql.language.UnionTypeExtensionDefinition) Collections.emptyList(java.util.Collections.emptyList) FieldDefinition(graphql.language.FieldDefinition) GraphQLInputType(graphql.schema.GraphQLInputType) Set(java.util.Set) TypeDefinition(graphql.language.TypeDefinition) GraphQLArgument(graphql.schema.GraphQLArgument) Collectors(java.util.stream.Collectors) Objects(java.util.Objects) NotAnOutputTypeError(graphql.schema.idl.errors.NotAnOutputTypeError) List(java.util.List) Stream(java.util.stream.Stream) ENUM_VALUE(graphql.introspection.Introspection.DirectiveLocation.ENUM_VALUE) InterfaceTypeDefinition(graphql.language.InterfaceTypeDefinition) Optional(java.util.Optional) GraphQLEnumType(graphql.schema.GraphQLEnumType) InterfaceTypeExtensionDefinition(graphql.language.InterfaceTypeExtensionDefinition) DirectiveLocation(graphql.introspection.Introspection.DirectiveLocation) GraphQLScalarType(graphql.schema.GraphQLScalarType) InputObjectTypeDefinition(graphql.language.InputObjectTypeDefinition) SchemaProblem(graphql.schema.idl.errors.SchemaProblem) HashMap(java.util.HashMap) GraphQLType(graphql.schema.GraphQLType) Stack(java.util.Stack) ArrayList(java.util.ArrayList) ENUM(graphql.introspection.Introspection.DirectiveLocation.ENUM) Introspection(graphql.introspection.Introspection) HashSet(java.util.HashSet) LinkedHashMap(java.util.LinkedHashMap) UnionTypeDefinition(graphql.language.UnionTypeDefinition) DataFetcherFactories(graphql.schema.DataFetcherFactories) InputObjectTypeExtensionDefinition(graphql.language.InputObjectTypeExtensionDefinition) ScalarTypeExtensionDefinition(graphql.language.ScalarTypeExtensionDefinition) DataFetcher(graphql.schema.DataFetcher) GraphQLSchema(graphql.schema.GraphQLSchema) ScalarTypeDefinition(graphql.language.ScalarTypeDefinition) EnumTypeExtensionDefinition(graphql.language.EnumTypeExtensionDefinition) GraphQLOutputType(graphql.schema.GraphQLOutputType) Directive(graphql.language.Directive) GraphQLTypeReference(graphql.schema.GraphQLTypeReference) PublicApi(graphql.PublicApi) Assert.assertNotNull(graphql.Assert.assertNotNull) GraphQLTypeReference.typeRef(graphql.schema.GraphQLTypeReference.typeRef) Collections(java.util.Collections) GraphQLEnumType(graphql.schema.GraphQLEnumType) GraphQLEnumValueDefinition(graphql.schema.GraphQLEnumValueDefinition) EnumTypeExtensionDefinition(graphql.language.EnumTypeExtensionDefinition)

Aggregations

Assert.assertNotNull (graphql.Assert.assertNotNull)1 GraphQLError (graphql.GraphQLError)1 PublicApi (graphql.PublicApi)1 Introspection (graphql.introspection.Introspection)1 DirectiveLocation (graphql.introspection.Introspection.DirectiveLocation)1 ENUM (graphql.introspection.Introspection.DirectiveLocation.ENUM)1 ENUM_VALUE (graphql.introspection.Introspection.DirectiveLocation.ENUM_VALUE)1 INPUT_FIELD_DEFINITION (graphql.introspection.Introspection.DirectiveLocation.INPUT_FIELD_DEFINITION)1 INPUT_OBJECT (graphql.introspection.Introspection.DirectiveLocation.INPUT_OBJECT)1 OBJECT (graphql.introspection.Introspection.DirectiveLocation.OBJECT)1 UNION (graphql.introspection.Introspection.DirectiveLocation.UNION)1 Directive (graphql.language.Directive)1 EnumTypeDefinition (graphql.language.EnumTypeDefinition)1 EnumTypeExtensionDefinition (graphql.language.EnumTypeExtensionDefinition)1 EnumValueDefinition (graphql.language.EnumValueDefinition)1 FieldDefinition (graphql.language.FieldDefinition)1 InputObjectTypeDefinition (graphql.language.InputObjectTypeDefinition)1 InputObjectTypeExtensionDefinition (graphql.language.InputObjectTypeExtensionDefinition)1 InputValueDefinition (graphql.language.InputValueDefinition)1 InterfaceTypeDefinition (graphql.language.InterfaceTypeDefinition)1