Interface GraphQLCodegenConfiguration
- All Known Implementing Classes:
MappingConfig,MappingContext
-
Method Summary
Modifier and TypeMethodDescriptionSpecifies whether generated classes should be annotated with @GeneratedSpecifies whether the@Generatedannotation should include thedateattribute.Specifies the strategy of generating api interfaces.Sets the prefix for GraphQL api classes (query, mutation, subscription).Sets prefix strategy for GraphQL api classes (query, mutation, subscription).Sets the suffix for GraphQL api classes (query, mutation, subscription).Java package for generated api classes (Query, Mutation, Subscription).Return type for api methods (query / subscription) that return list values For example: reactor.core.publisher.FluxReturn type for api methods (query / subscription) For example: reactor.core.publisher.MonoSpecifies the strategy of generating root api interface.Can be used to supply custom annotations (serializers) for scalars.Can be used to supply paths to custom FreeMarker templates for code generation.Can be used to specify the root directory for the custom FreeMaker templatesCan be used to supply custom mappings for scalars.Map GraphQL directives to Java annotations.Fields that WILL NOT be generated.Fields that require DataFetcherResult.Fields that DO NOT require Resolvers.Fields that require Resolvers.Enables the generation of the all$ method in the projection classes of the client.Specifies whether api classes should be generated.Whether signatures of API interface methods should havesuspendmodifier.Whether signatures of API interface methods should havethrows Exception.Specifies whether generated model classes should have builder.Specifies whether client-side classes should be generated for each query, mutation and subscription.Returns a qualified class name (with package) of the Generated annotation that will be added on top of every generated class.If true, then graphql.schema.DataFetchingEnvironment env will be added as a last argument to all methods of root type resolvers and field resolvers.Generate code with langSpecifies whether generated model classes should have equals and hashCode methods defined.Whether all fields in extensions (extend typeandextend interface) should be present in Resolver interface instead of the type class itself.Specifies whether generated model classes should be immutable.Specifies whether generated union interfaces should be annotated with a Jackson type id resolver generated in model package.default BooleanSpecifies whether generate public model classes.Specifies whether model classes should be generated for Query/Subscription/Mutation.default BooleanSpecifies whether model classes should have public or private fields.default BooleanSpecifies whether model classes should only have a no-args constructor.If true, then generate separate `Resolver` interface for parametrized fields.default BooleanSpecifies whether generate sealed interfaces.Specifies whether generated model classes should have toString method defined.default BooleanSpecifies whether classes should be generated with constructors setting the default value for nullable fields to null.Sets the prefix for GraphQL model classes (type, input, interface, enum, union).Sets the suffix for GraphQL model classes (type, input, interface, enum, union).Java package for generated model classes (type, input, interface, enum, union).Annotation for mandatory (NonNull) fields.Interface that will be added as "extend" to all generated api Mutation interfaces.Java package for generated classes.The suffix for `ParametrizedInput` classes.Annotations that will be added to all parametrized resolver methods.Interface that will be added as "extend" to all generated api Query interfaces.Relay-related configurations.The suffix for `Request` classes.Annotations that will be added to all resolver arguments.Interface that will be added as "extend" to all generated TypeResolver interfaces.Limit depth when `all$` invoke which has subProjectionsThe suffix for `ResponseProjection` classes.The suffix for `Response` classes.Interface that will be added as "extend" to all generated api Subscription interfaces.Return type for subscription methods.default BooleanSets the prefix for GraphQL type resolver classes.Sets the suffix for GraphQL type resolver classes.Types that must generated as interfaces.Specifies the name of the property to be included in api classes to support unknown fields during serialization or deserializationFields that require serialization usingObjectMapper.writeValueAsString(Object)Specifies whether return types of generated API interface should be wrapped intojava.util.OptionalSpecifies whether input types of generated input classes should be wrapped intoArgumentValue.Deprecated.Deprecated.UsegetGenerateModelsWithPublicFields()instead.Deprecated.UsegetGenerateNoArgsConstructorOnly()instead.Deprecated.UsegetGenerateSealedInterfaces()instead.Deprecated.UsegetInitializeNullableTypes()instead.Deprecated.UsegetSupportUnknownFields()instead.
-
Method Details
-
getCustomTypesMapping
Can be used to supply custom mappings for scalars.Supports:
- Map of (GraphqlObjectName.fieldName) to (JavaType)
- Map of (GraphqlType) to (JavaType)
E.g.:
DateTime --- StringPrice.amount --- java.math.BigDecimal
- Returns:
- mappings from GraphqlType to JavaType
-
getCustomTemplatesRoot
File getCustomTemplatesRoot()Can be used to specify the root directory for the custom FreeMaker templates- Returns:
- the directory source for the root directory
-
getCustomTemplates
Can be used to supply paths to custom FreeMarker templates for code generation.- Returns:
- a map, where key is a template type and a value is path to a FreeMarker template
-
getCustomAnnotationsMapping
Can be used to supply custom annotations (serializers) for scalars.Supports:
- Map of (GraphqlObjectName.fieldName) to (JavaAnnotation)
- Map of (GraphqlType) to (JavaAnnotation)
E.g.:
EpochMillis --- @com.fasterxml.jackson.databind.annotation.JsonDeserialize(using = com.example.json .EpochMillisScalarDeserializer.class)- Returns:
- mappings from GraphqlType to JavaAnnotation
-
getDirectiveAnnotationsMapping
Map GraphQL directives to Java annotations.Directive fields can be used in annotations via: {{directiveFieldName}}
Example:
schema: directive
@auth (roles: [String])directiveAnnotationsMapping: auth --- @org.springframework.security.access.annotation.Secured({{roles}})- Returns:
- mappings from GraphQL directives to Java annotations.
-
getGenerateApis
Boolean getGenerateApis()Specifies whether api classes should be generated.- Returns:
- true is API interfaces should be generated.
-
getGenerateModelsForRootTypes
Boolean getGenerateModelsForRootTypes()Specifies whether model classes should be generated for Query/Subscription/Mutation.- Returns:
- true is model classes (POJOs) should be generated for GraphQL root types.
-
getApiRootInterfaceStrategy
ApiRootInterfaceStrategy getApiRootInterfaceStrategy()Specifies the strategy of generating root api interface.- Returns:
- strategy of generating root api interface.
-
getApiInterfaceStrategy
ApiInterfaceStrategy getApiInterfaceStrategy()Specifies the strategy of generating api interfaces.- Returns:
- strategy of generating api interfaces.
-
getPackageName
String getPackageName()Java package for generated classes.- Returns:
- Java package for generated classes.
-
getApiPackageName
String getApiPackageName()Java package for generated api classes (Query, Mutation, Subscription).- Returns:
- Java package for generated api classes.
-
getModelPackageName
String getModelPackageName()Java package for generated model classes (type, input, interface, enum, union).- Returns:
- Java package for generated model classes.
-
getModelNamePrefix
String getModelNamePrefix()Sets the prefix for GraphQL model classes (type, input, interface, enum, union).- Returns:
- The prefix for GraphQL model classes.
-
getModelNameSuffix
String getModelNameSuffix()Sets the suffix for GraphQL model classes (type, input, interface, enum, union).- Returns:
- The suffix for GraphQL model classes.
-
getApiNamePrefixStrategy
ApiNamePrefixStrategy getApiNamePrefixStrategy()Sets prefix strategy for GraphQL api classes (query, mutation, subscription).- Returns:
- Prefix strategy for GraphQL api classes.
-
getApiNamePrefix
String getApiNamePrefix()Sets the prefix for GraphQL api classes (query, mutation, subscription).- Returns:
- The prefix for GraphQL api classes.
-
getApiNameSuffix
String getApiNameSuffix()Sets the suffix for GraphQL api classes (query, mutation, subscription).- Returns:
- The suffix for GraphQL api classes.
-
getModelValidationAnnotation
String getModelValidationAnnotation()Annotation for mandatory (NonNull) fields. Can be null/empty.- Returns:
- Annotation for mandatory (NonNull) fields
-
getApiReturnType
String getApiReturnType()Return type for api methods (query / subscription) For example: reactor.core.publisher.Mono- Returns:
- Return type for api methods (query / subscription)
-
getApiReturnListType
String getApiReturnListType()Return type for api methods (query / subscription) that return list values For example: reactor.core.publisher.Flux- Returns:
- Return type for api methods (query / subscription) that return list values
-
getSubscriptionReturnType
String getSubscriptionReturnType()Return type for subscription methods. For example: org.reactivestreams.Publisher, io.reactivex.Observable, etc.- Returns:
- Return type for subscription methods
-
getGenerateBuilder
Boolean getGenerateBuilder()Specifies whether generated model classes should have builder.- Returns:
- true if generated model classes should have builder.
-
getGenerateEqualsAndHashCode
Boolean getGenerateEqualsAndHashCode()Specifies whether generated model classes should have equals and hashCode methods defined.- Returns:
- true if generated model classes should have equals and hashCode methods defined.
-
getGenerateImmutableModels
Boolean getGenerateImmutableModels()Specifies whether generated model classes should be immutable.- Returns:
- true if generated model classes should be immutable.
-
getGenerateToString
Boolean getGenerateToString()Specifies whether generated model classes should have toString method defined.- Returns:
- true if generated model classes should have toString method defined.
-
getGenerateParameterizedFieldsResolvers
Boolean getGenerateParameterizedFieldsResolvers()If true, then generate separate `Resolver` interface for parametrized fields. If false, then add field to the type definition and ignore field parameters.- Returns:
- true if separate `Resolver` interface for parametrized fields should be generated. false if field should be added to the type definition and field parameters should be ignored.
-
getTypeResolverPrefix
String getTypeResolverPrefix()Sets the prefix for GraphQL type resolver classes.- Returns:
- The prefix for GraphQL type resolver classes.
-
getTypeResolverSuffix
String getTypeResolverSuffix()Sets the suffix for GraphQL type resolver classes.- Returns:
- The suffix for GraphQL type resolver classes.
-
getGenerateExtensionFieldsResolvers
Boolean getGenerateExtensionFieldsResolvers()Whether all fields in extensions (extend typeandextend interface) should be present in Resolver interface instead of the type class itself.- Returns:
- true if all fields in extensions (
extend typeandextend interface) should be present in Resolver interface instead of the type class itself.
-
getGenerateDataFetchingEnvironmentArgumentInApis
Boolean getGenerateDataFetchingEnvironmentArgumentInApis()If true, then graphql.schema.DataFetchingEnvironment env will be added as a last argument to all methods of root type resolvers and field resolvers.- Returns:
- true if graphql.schema.DataFetchingEnvironment env should be added as a last argument in all API interfaces methods.
-
getGenerateApisWithThrowsException
Boolean getGenerateApisWithThrowsException()Whether signatures of API interface methods should havethrows Exception.- Returns:
- true if API interfaces methods signature should contain
throws Exception.
-
getGenerateApisWithSuspendFunctions
Boolean getGenerateApisWithSuspendFunctions()Whether signatures of API interface methods should havesuspendmodifier.- Returns:
- true if API interfaces methods signature should contain
suspendmodifier.
-
getAddGeneratedAnnotation
Boolean getAddGeneratedAnnotation()Specifies whether generated classes should be annotated with @Generated- Returns:
- true if classes should be annotated with @Generated
-
getAddGeneratedAnnotationDate
Boolean getAddGeneratedAnnotationDate()Specifies whether the@Generatedannotation should include thedateattribute.- Returns:
- true if the
dateattribute should be included in the@Generatedannotation
-
getGenerateJacksonTypeIdResolver
Boolean getGenerateJacksonTypeIdResolver()Specifies whether generated union interfaces should be annotated with a Jackson type id resolver generated in model package.- Returns:
- true if union interfaces should be annotated with a Jackson type id resolver generated in model package
-
getRelayConfig
RelayConfig getRelayConfig()Relay-related configurations.- Returns:
- Relay-related configurations.
-
getFieldsWithResolvers
Fields that require Resolvers.Values should be defined here in format: TypeName, TypeName.fieldName, @directive
If just type is specified, then all fields of this type will have resolvers.
E.g.:
PersonPerson.friends@customResolver
- Returns:
- Set of types and fields that should have Resolver interfaces.
-
getFieldsWithoutResolvers
Fields that DO NOT require Resolvers.Values should be defined here in format: TypeName, TypeName.fieldName, @directive
If just type is specified, then all fields of this type will NOT have resolvers.
Can be used in conjunction with
generateExtensionFieldsResolversE.g.:
PersonPerson.friends@customResolver
- Returns:
- Set of types and fields that should NOT have Resolver interfaces.
-
getFieldsToExcludeFromGeneration
Fields that WILL NOT be generated.Values should be defined here in format: TypeName.fieldName
E.g.:
Person.friends
- Returns:
- Set of types and fields that should NOT be generated.
-
getFieldsWithDataFetcherResult
Fields that require DataFetcherResult.Values should be defined here in format: TypeName, TypeName.fieldName, @directive
E.g.:
@dataFetcherResult
- Returns:
- Set of types and fields that should have DataFetcherResult.
-
getUseOptionalForNullableReturnTypes
Boolean getUseOptionalForNullableReturnTypes()Specifies whether return types of generated API interface should be wrapped intojava.util.Optional- Returns:
- true if return types should be wrapped into
java.util.Optional
-
getUseWrapperForNullableInputTypes
Boolean getUseWrapperForNullableInputTypes()Specifies whether input types of generated input classes should be wrapped intoArgumentValue.- Returns:
- true if input types should be wrapped into
ArgumentValue
-
getGenerateClient
Boolean getGenerateClient()Specifies whether client-side classes should be generated for each query, mutation and subscription. This includes: `Request` class (contains input data) and `ResponseProjection` class (contains response fields).- Returns:
- true if client-side classes should be generated (`Request`, `Response` and `ResponseProjection`)
-
getRequestSuffix
String getRequestSuffix()The suffix for `Request` classes.- Returns:
- The suffix for `Request` classes.
-
getResponseSuffix
String getResponseSuffix()The suffix for `Response` classes.- Returns:
- The suffix for `Response` classes.
-
getResponseProjectionSuffix
String getResponseProjectionSuffix()The suffix for `ResponseProjection` classes.- Returns:
- The suffix for `ResponseProjection` classes.
-
getParametrizedInputSuffix
String getParametrizedInputSuffix()The suffix for `ParametrizedInput` classes.- Returns:
- The suffix for `ParametrizedInput` classes.
-
getQueryResolverParentInterface
String getQueryResolverParentInterface()Interface that will be added as "extend" to all generated api Query interfaces.- Returns:
- Parent interface of all GraphQL Query types.
-
getMutationResolverParentInterface
String getMutationResolverParentInterface()Interface that will be added as "extend" to all generated api Mutation interfaces.- Returns:
- Parent interface of all GraphQL Mutation types.
-
getSubscriptionResolverParentInterface
String getSubscriptionResolverParentInterface()Interface that will be added as "extend" to all generated api Subscription interfaces.- Returns:
- Parent interface of all GraphQL Subscription types.
-
getResolverParentInterface
String getResolverParentInterface()Interface that will be added as "extend" to all generated TypeResolver interfaces.- Returns:
- Parent interface of all Resolvers of GraphQL types.
-
getGenerateAllMethodInProjection
Boolean getGenerateAllMethodInProjection()Enables the generation of the all$ method in the projection classes of the client.- Returns:
- whether the generation is enabled.
-
getResponseProjectionMaxDepth
Integer getResponseProjectionMaxDepth()Limit depth when `all$` invoke which has subProjections- Returns:
- limit depth when the projection is constructed automatically
-
getUseObjectMapperForRequestSerialization
Fields that require serialization usingObjectMapper.writeValueAsString(Object)Values should be defined here in format: GraphqlObjectName.fieldName or GraphqlTypeName
If just type is specified, then all fields of this type will be serialized using ObjectMapper.
E.g.:
Person.createdDateTimeZonedDateTime
- Returns:
- Set of types and fields that should be serialized using
ObjectMapper.writeValueAsString(Object)
-
getTypesAsInterfaces
Types that must generated as interfaces.Values should be defined here in format: TypeName, @directive
E.g.:
Person@asInterface
- Returns:
- Set of types that should generated as interfaces.
-
getResolverArgumentAnnotations
Annotations that will be added to all resolver arguments.E.g.:
@org.springframework.graphql.data.method.annotation.Argument
- Returns:
- Set of annotations that every resolver argument will have.
-
getParametrizedResolverAnnotations
Annotations that will be added to all parametrized resolver methods.E.g.:
@org.springframework.graphql.data.method.annotation.Argument
- Returns:
- Set of annotations that every parametrized resolver method will have.
-
getGeneratedLanguage
GeneratedLanguage getGeneratedLanguage()Generate code with lang- Returns:
- GeneratedLanguage.KOTLIN or GeneratedLanguage.JAVA
-
getGenerateModelOpenClasses
Specifies whether generate public model classes.- Returns:
- false generate data class in kotlin and case class in scala
-
isGenerateModelOpenClasses
Deprecated.UsegetGenerateModelOpenClasses()instead. -
getInitializeNullableTypes
Specifies whether classes should be generated with constructors setting the default value for nullable fields to null.- Returns:
- true if nullable fields should be defaulted to null.
-
isInitializeNullableTypes
Deprecated.UsegetInitializeNullableTypes()instead. -
getGenerateSealedInterfaces
Specifies whether generate sealed interfaces.- Returns:
- false generate sealed interfaces class in kotlin
-
isGenerateSealedInterfaces
Deprecated.UsegetGenerateSealedInterfaces()instead. -
getSupportUnknownFields
-
isSupportUnknownFields
Deprecated.UsegetSupportUnknownFields()instead. -
getUnknownFieldsPropertyName
String getUnknownFieldsPropertyName()Specifies the name of the property to be included in api classes to support unknown fields during serialization or deserialization- Returns:
- The name of the property to store unknown fields
-
getGeneratedAnnotation
String getGeneratedAnnotation()Returns a qualified class name (with package) of the Generated annotation that will be added on top of every generated class.- Returns:
- The name of the class for @Generated annotation
- See Also:
-
- "jakarta.annotation.Generated"
- "javax.annotation.processing.Generated"
- "javax.annotation.Generated"
-
getGenerateNoArgsConstructorOnly
Specifies whether model classes should only have a no-args constructor. All-args constructor will not be generated in case returned value is true- Returns:
- true if only no-args constructor should be generated. false if both no-args and all-args constructors should be generated
-
isGenerateNoArgsConstructorOnly
Deprecated.UsegetGenerateNoArgsConstructorOnly()instead. -
getGenerateModelsWithPublicFields
Specifies whether model classes should have public or private fields.- Returns:
- true if model classes should have public fields and no getters/setters. false if model classes should have private fields and getters/setters.
-
isGenerateModelsWithPublicFields
Deprecated.UsegetGenerateModelsWithPublicFields()instead.
-
getGenerateModelOpenClasses()instead.