public class JavaGraphQLTypeMapper extends GraphQLTypeMapper
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
JAVA_UTIL_LIST |
static java.util.regex.Pattern |
JAVA_UTIL_LIST_ELEMENT_REGEX |
| Constructor and Description |
|---|
JavaGraphQLTypeMapper() |
| Modifier and Type | Method and Description |
|---|---|
NamedDefinition |
getLanguageType(MappingContext mappingContext,
java.lang.String graphQLType,
java.lang.String name,
java.lang.String parentTypeName,
boolean mandatory,
boolean collection,
java.util.List<graphql.language.Directive> directives)
Convert GraphQL type to a corresponding language-specific type (java/scala/kotlin/etc)
|
static boolean |
isJavaPrimitive(java.lang.String possiblyPrimitiveType) |
boolean |
isPrimitive(java.lang.String possiblyPrimitiveType)
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)
Wrap return type of the API interface with generics and/or Optional and/or apiReturnType
(as specified 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, getMandatoryType, getNestedTypeName, getResponseReturnType, getTypeConsideringPrimitive, isInterfaceOrUnionpublic static final java.lang.String JAVA_UTIL_LIST
public static final java.util.regex.Pattern JAVA_UTIL_LIST_ELEMENT_REGEX
public static boolean isJavaPrimitive(java.lang.String possiblyPrimitiveType)
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)
wrapApiReturnTypeIfRequired in class GraphQLTypeMappermappingContext - Global mapping contextnamedDefinition - Named definitionparentTypeName - Name of the parent typepublic boolean isPrimitive(java.lang.String possiblyPrimitiveType)
GraphQLTypeMapperisPrimitive in class GraphQLTypeMapperpossiblyPrimitiveType - type to checkpublic NamedDefinition getLanguageType(MappingContext mappingContext, java.lang.String graphQLType, java.lang.String name, java.lang.String parentTypeName, boolean mandatory, boolean collection, java.util.List<graphql.language.Directive> directives)
GraphQLTypeMappergetLanguageType in class GraphQLTypeMappermappingContext - Global mapping contextgraphQLType - GraphQL typename - GraphQL type nameparentTypeName - Name of the parent typemandatory - GraphQL type is non-nullcollection - GraphQL type is collectiondirectives - GraphQL field directivespublic 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