public class KotlinGraphQLTypeMapper extends GraphQLTypeMapper
| Modifier and Type | Field and Description |
|---|---|
static java.util.regex.Pattern |
KOTLIN_UTIL_LIST_ELEMENT_REGEX |
| Constructor and Description |
|---|
KotlinGraphQLTypeMapper() |
| Modifier and Type | Method and Description |
|---|---|
static java.lang.String |
defaultValueKotlinPrimitive(java.lang.String kotlinType)
This method is used in kotlin template, do not remove it.
|
java.lang.String |
getResponseReturnType(MappingContext mappingContext,
ExtendedFieldDefinition operationDef,
NamedDefinition namedDefinition,
java.lang.String computedTypeName) |
java.lang.String |
getTypeConsideringPrimitive(MappingContext mappingContext,
NamedDefinition namedDefinition,
java.lang.String computedTypeName) |
static boolean |
isKotlinPrimitive(java.lang.String scalaType) |
boolean |
isPrimitive(java.lang.String kotlinType)
Check if the time is primitive.
|
java.lang.String |
wrapApiDefaultValueIfRequired(MappingContext mappingContext,
NamedDefinition namedDefinition,
graphql.language.InputValueDefinition inputValueDefinition,
java.lang.String defaultValue,
java.lang.String parentTypeName)
Wraps type into ArgumentValue, if required.
|
java.lang.String |
wrapApiInputTypeIfRequired(MappingContext mappingContext,
NamedDefinition namedDefinition,
java.lang.String parentTypeName)
Wraps type into ArgumentValue, if required.
|
java.lang.String |
wrapApiReturnTypeIfRequired(MappingContext mappingContext,
NamedDefinition namedDefinition,
java.lang.String parentTypeName)
Wraps type into apiReturnType or subscriptionReturnType (defined in the mapping configuration).
|
java.lang.String |
wrapIntoList(MappingContext mappingContext,
java.lang.String type,
boolean mandatory)
Wrap language-specific type (java/scala/kotlin/etc) into
List. |
java.lang.String |
wrapSuperTypeIntoList(MappingContext mappingContext,
java.lang.String type,
boolean mandatory)
Return upper bounded wildcard for the given interface type:
"Foo" becomes "List<? extends Foo>". |
getDirectives, getGenericsString, getLanguageType, getLanguageType, getLanguageType, getLanguageType, getLanguageType, getLanguageType, getMandatoryType, getNestedTypeName, isInterfaceOrUnionpublic static final java.util.regex.Pattern KOTLIN_UTIL_LIST_ELEMENT_REGEX
public static boolean isKotlinPrimitive(java.lang.String scalaType)
public static java.lang.String defaultValueKotlinPrimitive(java.lang.String kotlinType)
kotlinType - type get from Type templatepublic java.lang.String wrapIntoList(MappingContext mappingContext, java.lang.String type, boolean mandatory)
GraphQLTypeMapperList.
E.g.: String becomes List<String>wrapIntoList in class GraphQLTypeMappermappingContext - Global mapping contexttype - The name of a type that will be wrapped into List<>mandatory - Type is it mandatoryList<>public java.lang.String wrapSuperTypeIntoList(MappingContext mappingContext, java.lang.String type, boolean mandatory)
GraphQLTypeMapper"Foo" becomes "List<? extends Foo>".wrapSuperTypeIntoList in class GraphQLTypeMappermappingContext - Global mapping contexttype - The name of a type whose upper bound wildcard will be wrapped into a list.mandatory - Type is it mandatorypublic java.lang.String wrapApiReturnTypeIfRequired(MappingContext mappingContext, NamedDefinition namedDefinition, java.lang.String parentTypeName)
GraphQLTypeMapperExample 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>
wrapApiReturnTypeIfRequired in class GraphQLTypeMappermappingContext - Global mapping contextnamedDefinition - Named definitionparentTypeName - Name of the parent typepublic boolean isPrimitive(java.lang.String kotlinType)
GraphQLTypeMapperisPrimitive in class GraphQLTypeMapperkotlinType - type to checkpublic java.lang.String getTypeConsideringPrimitive(MappingContext mappingContext, NamedDefinition namedDefinition, java.lang.String computedTypeName)
getTypeConsideringPrimitive in class GraphQLTypeMapperpublic java.lang.String getResponseReturnType(MappingContext mappingContext, ExtendedFieldDefinition operationDef, NamedDefinition namedDefinition, java.lang.String computedTypeName)
getResponseReturnType in class GraphQLTypeMapperpublic java.lang.String wrapApiInputTypeIfRequired(MappingContext mappingContext, NamedDefinition namedDefinition, java.lang.String parentTypeName)
GraphQLTypeMapperExample 1:
* Given GraphQL schema: input MyInput { name: String! }
* Given config: useWrapperForNullableInputTypes = true
* Return: String
Example 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>
wrapApiInputTypeIfRequired in class GraphQLTypeMappermappingContext - Global mapping contextnamedDefinition - Named definitionparentTypeName - Name of the parent typepublic java.lang.String wrapApiDefaultValueIfRequired(MappingContext mappingContext, NamedDefinition namedDefinition, graphql.language.InputValueDefinition inputValueDefinition, java.lang.String defaultValue, java.lang.String parentTypeName)
GraphQLTypeMapperExample 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")
wrapApiDefaultValueIfRequired in class GraphQLTypeMappermappingContext - Global mapping contextnamedDefinition - Named definitioninputValueDefinition - Input value definitiondefaultValue - Default valueparentTypeName - Name of the parent type