public abstract class GraphQLTypeMapper
extends java.lang.Object
| Constructor and Description |
|---|
GraphQLTypeMapper() |
| Modifier and Type | Method and Description |
|---|---|
static java.util.List<graphql.language.Directive> |
getDirectives(graphql.language.NamedNode<?> def) |
java.lang.String |
getGenericsString(MappingContext mappingContext,
java.lang.String genericType,
java.lang.String typeParameter)
Wrap string into generics type
|
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)
|
java.lang.String |
getLanguageType(MappingContext mappingContext,
graphql.language.Type<?> type)
Convert GraphQL type to a corresponding language-specific type
|
NamedDefinition |
getLanguageType(MappingContext mappingContext,
graphql.language.Type<?> graphqlType,
java.lang.String name,
java.lang.String parentTypeName)
Convert GraphQL type to a corresponding language-specific type (java/scala/kotlin/etc)
|
NamedDefinition |
getLanguageType(MappingContext mappingContext,
graphql.language.Type<?> graphqlType,
java.lang.String name,
java.lang.String parentTypeName,
boolean mandatory,
boolean collection)
Convert GraphQL type to a corresponding language-specific type (java/scala/kotlin/etc)
|
NamedDefinition |
getLanguageType(MappingContext mappingContext,
graphql.language.Type<?> 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)
|
NamedDefinition |
getLanguageType(MappingContext mappingContext,
graphql.language.Type<?> graphqlType,
java.lang.String name,
java.lang.String parentTypeName,
java.util.List<graphql.language.Directive> directives)
Convert GraphQL type to a corresponding language-specific type (java/scala/kotlin/etc)
|
static java.lang.String |
getMandatoryType(java.lang.String typeName) |
static java.lang.String |
getNestedTypeName(graphql.language.Type<?> graphqlType)
Get nested type of GraphQL Type.
|
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) |
protected boolean |
isInterfaceOrUnion(MappingContext mappingContext,
java.lang.String graphQLType) |
abstract boolean |
isPrimitive(java.lang.String possiblyPrimitiveType)
Check if the time is primitive.
|
abstract 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.
|
abstract java.lang.String |
wrapApiInputTypeIfRequired(MappingContext mappingContext,
NamedDefinition namedDefinition,
java.lang.String parentTypeName)
Wraps type into ArgumentValue, if required.
|
abstract java.lang.String |
wrapApiReturnTypeIfRequired(MappingContext mappingContext,
NamedDefinition namedDefinition,
java.lang.String parentTypeName)
Wraps type into apiReturnType or subscriptionReturnType (defined in the mapping configuration).
|
abstract java.lang.String |
wrapIntoList(MappingContext mappingContext,
java.lang.String type,
boolean mandatory)
Wrap language-specific type (java/scala/kotlin/etc) into
List. |
abstract 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>". |
public static java.lang.String getNestedTypeName(graphql.language.Type<?> graphqlType)
Event -> Event
Event! -> Event
[Event!]! -> Event
[[Event]] -> EventgraphqlType - GraphQL typepublic static java.lang.String getMandatoryType(java.lang.String typeName)
public static java.util.List<graphql.language.Directive> getDirectives(graphql.language.NamedNode<?> def)
public abstract java.lang.String wrapIntoList(MappingContext mappingContext, java.lang.String type, boolean mandatory)
List.
E.g.: String becomes List<String>type - The name of a type that will be wrapped into List<>mappingContext - Global mapping contextmandatory - Type is it mandatoryList<>public abstract java.lang.String wrapSuperTypeIntoList(MappingContext mappingContext, java.lang.String type, boolean mandatory)
"Foo" becomes "List<? extends Foo>".type - The name of a type whose upper bound wildcard will be wrapped into a list.mappingContext - Global mapping contextmandatory - Type is it mandatorypublic abstract java.lang.String wrapApiReturnTypeIfRequired(MappingContext mappingContext, NamedDefinition namedDefinition, java.lang.String parentTypeName)
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>
mappingContext - Global mapping contextnamedDefinition - Named definitionparentTypeName - Name of the parent typepublic abstract java.lang.String wrapApiInputTypeIfRequired(MappingContext mappingContext, NamedDefinition namedDefinition, java.lang.String parentTypeName)
Example 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>
mappingContext - Global mapping contextnamedDefinition - Named definitionparentTypeName - Name of the parent typepublic abstract java.lang.String wrapApiDefaultValueIfRequired(MappingContext mappingContext, NamedDefinition namedDefinition, graphql.language.InputValueDefinition inputValueDefinition, java.lang.String defaultValue, java.lang.String parentTypeName)
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")
mappingContext - Global mapping contextnamedDefinition - Named definitioninputValueDefinition - Input value definitiondefaultValue - Default valueparentTypeName - Name of the parent typepublic abstract boolean isPrimitive(java.lang.String possiblyPrimitiveType)
possiblyPrimitiveType - type to checkpublic java.lang.String getGenericsString(MappingContext mappingContext, java.lang.String genericType, java.lang.String typeParameter)
mappingContext - Global mapping contextgenericType - Generics typetypeParameter - Parameter of generics typepublic java.lang.String getLanguageType(MappingContext mappingContext, graphql.language.Type<?> type)
mappingContext - Global mapping contexttype - GraphQL typepublic NamedDefinition getLanguageType(MappingContext mappingContext, graphql.language.Type<?> graphqlType, java.lang.String name, java.lang.String parentTypeName)
mappingContext - Global mapping contextgraphqlType - GraphQL typename - GraphQL type nameparentTypeName - Name of the parent typepublic NamedDefinition getLanguageType(MappingContext mappingContext, graphql.language.Type<?> graphqlType, java.lang.String name, java.lang.String parentTypeName, java.util.List<graphql.language.Directive> directives)
mappingContext - Global mapping contextgraphqlType - GraphQL typename - GraphQL type nameparentTypeName - Name of the parent typedirectives - GraphQL field directivespublic NamedDefinition getLanguageType(MappingContext mappingContext, graphql.language.Type<?> graphqlType, java.lang.String name, java.lang.String parentTypeName, boolean mandatory, boolean collection)
mappingContext - Global mapping contextgraphqlType - GraphQL typename - GraphQL type nameparentTypeName - Name of the parent typemandatory - GraphQL type is non-nullcollection - GraphQL type is collectionpublic NamedDefinition getLanguageType(MappingContext mappingContext, graphql.language.Type<?> graphqlType, java.lang.String name, java.lang.String parentTypeName, boolean mandatory, boolean collection, java.util.List<graphql.language.Directive> directives)
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 directivespublic 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)
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 directivespublic java.lang.String getTypeConsideringPrimitive(MappingContext mappingContext, NamedDefinition namedDefinition, java.lang.String computedTypeName)
public java.lang.String getResponseReturnType(MappingContext mappingContext, ExtendedFieldDefinition operationDef, NamedDefinition namedDefinition, java.lang.String computedTypeName)
protected boolean isInterfaceOrUnion(MappingContext mappingContext, java.lang.String graphQLType)