public class ScalaGraphQLTypeMapper extends GraphQLTypeMapper
| Constructor and Description |
|---|
ScalaGraphQLTypeMapper() |
| Modifier and Type | Method and Description |
|---|---|
static java.lang.String |
getGenericParameter(java.lang.String scalaType) |
java.lang.String |
getGenericsString(MappingContext mappingContext,
java.lang.String genericType,
java.lang.String typeParameter)
Wrap string into generics type
|
boolean |
isPrimitive(java.lang.String scalaType)
Check if the time is primitive.
|
static boolean |
isScalaCollection(java.lang.String scalaType) |
static boolean |
isScalaOption(java.lang.String scalaType) |
static boolean |
isScalaPrimitive(java.lang.String scalaType) |
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, getLanguageType, getLanguageType, getLanguageType, getLanguageType, getLanguageType, getLanguageType, getMandatoryType, getNestedTypeName, getResponseReturnType, getTypeConsideringPrimitive, isInterfaceOrUnionpublic static boolean isScalaPrimitive(java.lang.String scalaType)
public static boolean isScalaOption(java.lang.String scalaType)
public static boolean isScalaCollection(java.lang.String scalaType)
public static java.lang.String getGenericParameter(java.lang.String scalaType)
public 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 scalaType)
GraphQLTypeMapperisPrimitive in class GraphQLTypeMapperscalaType - type to checkpublic java.lang.String getGenericsString(MappingContext mappingContext, java.lang.String genericType, java.lang.String typeParameter)
GraphQLTypeMappergetGenericsString in class GraphQLTypeMappermappingContext - Global mapping contextgenericType - Generics typetypeParameter - Parameter of generics typepublic 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