Package graphql.schema
Class GraphQLTypeUtil
java.lang.Object
graphql.schema.GraphQLTypeUtil
A utility class that helps work with
GraphQLTypes-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanisEnum(GraphQLType type) Returns true if the given type is an enum typestatic booleanisInput(GraphQLType type) Returns true if the given type is an input typestatic booleanstatic booleanisLeaf(GraphQLType type) Returns true if the given type is a leaf type, that it cant contain any more fieldsstatic booleanisList(GraphQLType type) Returns true if the given type is a list typestatic booleanisNonNull(GraphQLType type) Returns true if the given type is a non null typestatic booleanisNotWrapped(GraphQLType type) Returns true if the given type is NOT a non null or list typestatic booleanisNullable(GraphQLType type) Returns true if the given type is a nullable typestatic booleanisObjectType(GraphQLType type) static booleanisScalar(GraphQLType type) Returns true if the given type is a scalar typestatic Predicate<GraphQLNamedSchemaElement> This predicate returns true if the schema element is an inbuilt schema element such as the system scalars and directives or introspection typesstatic booleanisWrapped(GraphQLType type) Returns true if the given type is a non null or list type, that is a wrapped typestatic StringsimplePrint(GraphQLSchemaElement schemaElement) static StringsimplePrint(GraphQLType type) This will return the type in graphql SDL format, eg [typeName!]!static GraphQLUnmodifiedTypeunwrapAll(GraphQLType type) Unwraps all layers of the type or just returns the type again if it's not a wrapped type NOTE: This method does not support GraphQLTypeReference as input and will lead to a ClassCastExceptionstatic <T extends GraphQLType>
TunwrapAllAs(GraphQLType type) Unwraps all layers of the type or just returns the type again if it's not a wrapped type and then cast to the target type.static GraphQLTypeunwrapNonNull(GraphQLType type) Unwraps all non nullable layers of the type until it reaches a type that is notGraphQLNonNullstatic <T extends GraphQLType>
TunwrapNonNullAs(GraphQLType type) Unwraps all non nullable layers of the type until it reaches a type that is notGraphQLNonNulland then cast to the target type.static GraphQLTypeunwrapOne(GraphQLType type) Unwraps one layer of the type or just returns the type again if it's not a wrapped typestatic <T extends GraphQLType>
TunwrapOneAs(GraphQLType type) Unwraps one layer of the type or just returns the type again if it's not a wrapped type and then cast to the target type.static Stack<GraphQLType> unwrapType(GraphQLType type) graphql types can be wrapped inGraphQLNonNullandGraphQLListtype wrappers so this method will unwrap the type down to the raw unwrapped type and return that wrapping as a stack, with the top of the stack being the raw underling type.
-
Constructor Details
-
GraphQLTypeUtil
public GraphQLTypeUtil()
-
-
Method Details
-
simplePrint
This will return the type in graphql SDL format, eg [typeName!]!- Parameters:
type- the type in play- Returns:
- the type in graphql SDL format, eg [typeName!]!
-
simplePrint
-
isNonNull
Returns true if the given type is a non null type- Parameters:
type- the type to check- Returns:
- true if the given type is a non null type
-
isNullable
Returns true if the given type is a nullable type- Parameters:
type- the type to check- Returns:
- true if the given type is a nullable type
-
isList
Returns true if the given type is a list type- Parameters:
type- the type to check- Returns:
- true if the given type is a list type
-
isWrapped
Returns true if the given type is a non null or list type, that is a wrapped type- Parameters:
type- the type to check- Returns:
- true if the given type is a non null or list type
-
isNotWrapped
Returns true if the given type is NOT a non null or list type- Parameters:
type- the type to check- Returns:
- true if the given type is NOT a non null or list type
-
isScalar
Returns true if the given type is a scalar type- Parameters:
type- the type to check- Returns:
- true if the given type is a scalar type
-
isEnum
Returns true if the given type is an enum type- Parameters:
type- the type to check- Returns:
- true if the given type is an enum type
-
isLeaf
Returns true if the given type is a leaf type, that it cant contain any more fields- Parameters:
type- the type to check- Returns:
- true if the given type is a leaf type
-
isInput
Returns true if the given type is an input type- Parameters:
type- the type to check- Returns:
- true if the given type is an input type
-
unwrapOne
Unwraps one layer of the type or just returns the type again if it's not a wrapped type- Parameters:
type- the type to unwrapOne- Returns:
- the unwrapped type or the same type again if it's not wrapped
-
unwrapOneAs
Unwraps one layer of the type or just returns the type again if it's not a wrapped type and then cast to the target type.- Type Parameters:
T- for two- Parameters:
type- the type to unwrapOne- Returns:
- the unwrapped type or the same type again if it's not wrapped
-
unwrapAll
Unwraps all layers of the type or just returns the type again if it's not a wrapped type NOTE: This method does not support GraphQLTypeReference as input and will lead to a ClassCastException- Parameters:
type- the type to unwrapOne- Returns:
- the underlying type
-
unwrapAllAs
Unwraps all layers of the type or just returns the type again if it's not a wrapped type and then cast to the target type.- Type Parameters:
T- for two- Parameters:
type- the type to unwrapOne- Returns:
- the underlying type
-
unwrapNonNull
Unwraps all non nullable layers of the type until it reaches a type that is notGraphQLNonNull- Parameters:
type- the type to unwrap- Returns:
- the underlying type that is not
GraphQLNonNull
-
unwrapNonNullAs
Unwraps all non nullable layers of the type until it reaches a type that is notGraphQLNonNulland then cast to the target type.- Type Parameters:
T- for two- Parameters:
type- the type to unwrap- Returns:
- the underlying type that is not
GraphQLNonNull
-
unwrapType
graphql types can be wrapped inGraphQLNonNullandGraphQLListtype wrappers so this method will unwrap the type down to the raw unwrapped type and return that wrapping as a stack, with the top of the stack being the raw underling type.- Parameters:
type- the type to unwrap- Returns:
- a stack of the type wrapping which will be at least 1 later deep
-
isInterfaceOrUnion
-
isObjectType
-
isSystemElement
This predicate returns true if the schema element is an inbuilt schema element such as the system scalars and directives or introspection types- Returns:
- true if it's a system schema element
-