Class KotlinGraphQLTypeMapper
- Since:
- 2020/12/09
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringdefaultValueKotlinPrimitive(String kotlinType) This method is used in kotlin template, do not remove it.getResponseReturnType(MappingContext mappingContext, ExtendedFieldDefinition operationDef, NamedDefinition namedDefinition, String computedTypeName) getTypeConsideringPrimitive(MappingContext mappingContext, NamedDefinition namedDefinition, String computedTypeName) static booleanisKotlinPrimitive(String scalaType) booleanisPrimitive(String kotlinType) Check if the time is primitive.wrapApiDefaultValueIfRequired(MappingContext mappingContext, NamedDefinition namedDefinition, graphql.language.InputValueDefinition inputValueDefinition, String defaultValue, String parentTypeName) Wraps type into ArgumentValue, if required.wrapApiInputTypeIfRequired(MappingContext mappingContext, NamedDefinition namedDefinition, String parentTypeName) Wraps type into ArgumentValue, if required.wrapApiReturnTypeIfRequired(MappingContext mappingContext, NamedDefinition namedDefinition, String parentTypeName) Wraps type into apiReturnType or subscriptionReturnType (defined in the mapping configuration).wrapIntoList(MappingContext mappingContext, String type, boolean mandatory) Wrap language-specific type (java/kotlin/etc) intoList.wrapSuperTypeIntoList(MappingContext mappingContext, String type, boolean mandatory) Return upper bounded wildcard for the given interface type:"Foo"becomes"List<? extends Foo>".Methods inherited from class io.github.besi97.graphql.codegen.mapper.GraphQLTypeMapper
getDirectives, getGenericsString, getLanguageType, getLanguageType, getLanguageType, getLanguageType, getLanguageType, getLanguageType, getMandatoryType, getNestedTypeName, isInterfaceOrUnion
-
Field Details
-
KOTLIN_UTIL_LIST_ELEMENT_REGEX
-
-
Constructor Details
-
KotlinGraphQLTypeMapper
public KotlinGraphQLTypeMapper()
-
-
Method Details
-
isKotlinPrimitive
-
defaultValueKotlinPrimitive
This method is used in kotlin template, do not remove it.- Parameters:
kotlinType- type get from Type template- Returns:
- default value
-
wrapIntoList
Description copied from class:GraphQLTypeMapper- Specified by:
wrapIntoListin classGraphQLTypeMapper- Parameters:
mappingContext- Global mapping contexttype- The name of a type that will be wrapped intoList<>mandatory- Type is it mandatory- Returns:
- String The name of the given type, wrapped into
List<>
-
wrapSuperTypeIntoList
Description copied from class:GraphQLTypeMapperReturn upper bounded wildcard for the given interface type:"Foo"becomes"List<? extends Foo>".- Specified by:
wrapSuperTypeIntoListin classGraphQLTypeMapper- Parameters:
mappingContext- Global mapping contexttype- The name of a type whose upper bound wildcard will be wrapped into a list.mandatory- Type is it mandatory- Returns:
- String The name of the the wrapped type.
-
wrapApiReturnTypeIfRequired
public String wrapApiReturnTypeIfRequired(MappingContext mappingContext, NamedDefinition namedDefinition, String parentTypeName) Description copied from class:GraphQLTypeMapperWraps type into apiReturnType or subscriptionReturnType (defined in the mapping configuration).Example 1: * Given GraphQL schema:
type Query { events: [Event!]! }* Given config:useOptionalForNullableReturnTypes = true* Return:java.util.Optional<Event>Example 2: * Given GraphQL schema:
type Subscription { eventsCreated: [Event!]! }* Given subscriptionReturnType in config:org.reactivestreams.Publisher* Return:org.reactivestreams.Publisher<Event>Example 3: * Given GraphQL schema:
type Mutation { createEvent(inp: Inp): Event }* Given apiReturnType in config:reactor.core.publisher.Mono* Return:reactor.core.publisher.Mono<Event>Example 4: * Given GraphQL schema:
type Query { events: [Event!]! }* Given apiReturnListType in config:reactor.core.publisher.Flux* Return:reactor.core.publisher.Flux<Event>- Specified by:
wrapApiReturnTypeIfRequiredin classGraphQLTypeMapper- Parameters:
mappingContext- Global mapping contextnamedDefinition- Named definitionparentTypeName- Name of the parent type- Returns:
- Java/Kotlin type wrapped into the subscriptionReturnType
-
isPrimitive
Description copied from class:GraphQLTypeMapperCheck if the time is primitive.- Specified by:
isPrimitivein classGraphQLTypeMapper- Parameters:
kotlinType- type to check- Returns:
- true if the provided type is primitive, false if the provided type is not primitive
-
getTypeConsideringPrimitive
public String getTypeConsideringPrimitive(MappingContext mappingContext, NamedDefinition namedDefinition, String computedTypeName) - Overrides:
getTypeConsideringPrimitivein classGraphQLTypeMapper
-
getResponseReturnType
public String getResponseReturnType(MappingContext mappingContext, ExtendedFieldDefinition operationDef, NamedDefinition namedDefinition, String computedTypeName) - Overrides:
getResponseReturnTypein classGraphQLTypeMapper
-
wrapApiInputTypeIfRequired
public String wrapApiInputTypeIfRequired(MappingContext mappingContext, NamedDefinition namedDefinition, String parentTypeName) Description copied from class:GraphQLTypeMapperWraps type into ArgumentValue, if required.Example 1: * Given GraphQL schema:
input MyInput { name: String! }* Given config:useWrapperForNullableInputTypes = true* Return:StringExample 2: * Given GraphQL schema:
input MyInput { name: String }* Given config:useWrapperForNullableInputTypes = true* Return:ArgumentValue<String>Example 2: * Given GraphQL schema:
input MyInput { name: String[] }* Given config:useWrapperForNullableInputTypes = true* Return:List<String>- Specified by:
wrapApiInputTypeIfRequiredin classGraphQLTypeMapper- Parameters:
mappingContext- Global mapping contextnamedDefinition- Named definitionparentTypeName- Name of the parent type- Returns:
- Java type wrapped into ArgumentValue
-
wrapApiDefaultValueIfRequired
public String wrapApiDefaultValueIfRequired(MappingContext mappingContext, NamedDefinition namedDefinition, graphql.language.InputValueDefinition inputValueDefinition, String defaultValue, String parentTypeName) Description copied from class:GraphQLTypeMapperWraps type into ArgumentValue, if required.Example 1: * Given GraphQL schema:
input MyInput { name: String }* Given config:useWrapperForNullableInputTypes = true* Return:ArgumentValue.omitted()Example 2: * Given GraphQL schema:
input MyInput { name: String = null }* Given config:useWrapperForNullableInputTypes = true* Return:ArgumentValue.ofNullable(null)Example 2: * Given GraphQL schema:
input MyInput { name: String = "some value" }* Given config:useWrapperForNullableInputTypes = true* Return:ArgumentValue.ofNullable("some value")- Specified by:
wrapApiDefaultValueIfRequiredin classGraphQLTypeMapper- Parameters:
mappingContext- Global mapping contextnamedDefinition- Named definitioninputValueDefinition- Input value definitiondefaultValue- Default valueparentTypeName- Name of the parent type- Returns:
- Java type wrapped into ArgumentValue
-