Class JavaGraphQLTypeMapper
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetLanguageType(MappingContext mappingContext, String graphQLType, String name, String parentTypeName, boolean mandatory, boolean collection, List<graphql.language.Directive> directives) Convert GraphQL type to a corresponding language-specific type (java/kotlin/etc)static booleanisJavaPrimitive(String possiblyPrimitiveType) booleanisPrimitive(String possiblyPrimitiveType) 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) Wrap return type of the API interface with generics and/or Optional and/or apiReturnType (as specified 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, getMandatoryType, getNestedTypeName, getResponseReturnType, getTypeConsideringPrimitive, isInterfaceOrUnion
-
Field Details
-
JAVA_UTIL_LIST
- See Also:
-
JAVA_UTIL_LIST_ELEMENT_REGEX
-
-
Constructor Details
-
JavaGraphQLTypeMapper
public JavaGraphQLTypeMapper()
-
-
Method Details
-
isJavaPrimitive
-
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) Wrap return type of the API interface with generics and/or Optional and/or apiReturnType (as specified in the mapping configuration)- Specified by:
wrapApiReturnTypeIfRequiredin classGraphQLTypeMapper- Parameters:
mappingContext- Global mapping contextnamedDefinition- Named definitionparentTypeName- Name of the parent type- Returns:
- API interface name
-
isPrimitive
Description copied from class:GraphQLTypeMapperCheck if the time is primitive.- Specified by:
isPrimitivein classGraphQLTypeMapper- Parameters:
possiblyPrimitiveType- type to check- Returns:
- true if the provided type is primitive, false if the provided type is not primitive
-
getLanguageType
public NamedDefinition getLanguageType(MappingContext mappingContext, String graphQLType, String name, String parentTypeName, boolean mandatory, boolean collection, List<graphql.language.Directive> directives) Description copied from class:GraphQLTypeMapperConvert GraphQL type to a corresponding language-specific type (java/kotlin/etc)- Overrides:
getLanguageTypein classGraphQLTypeMapper- Parameters:
mappingContext- Global mapping contextgraphQLType- GraphQL typename- GraphQL type nameparentTypeName- Name of the parent typemandatory- GraphQL type is non-nullcollection- GraphQL type is collectiondirectives- GraphQL field directives- Returns:
- Corresponding language-specific type (java/kotlin/etc)
-
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
-