Package graphql.schema
Class GraphQLTypeUtil
java.lang.Object
graphql.schema.GraphQLTypeUtil
A utility class that helps work with
GraphQLType
s-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
isEnum
(GraphQLType type) Returns true if the given type is an enum typestatic boolean
isInput
(GraphQLType type) Returns true if the given type is an input typestatic boolean
static boolean
isLeaf
(GraphQLType type) Returns true if the given type is a leaf type, that it cant contain any more fieldsstatic boolean
isList
(GraphQLType type) Returns true if the given type is a list typestatic boolean
isNonNull
(GraphQLType type) Returns true if the given type is a non null typestatic boolean
isNotWrapped
(GraphQLType type) Returns true if the given type is NOT a non null or list typestatic boolean
isNullable
(GraphQLType type) Returns true if the given type is a nullable typestatic boolean
isObjectType
(GraphQLType type) static boolean
isScalar
(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 boolean
isWrapped
(GraphQLType type) Returns true if the given type is a non null or list type, that is a wrapped typestatic String
simplePrint
(GraphQLSchemaElement schemaElement) static String
simplePrint
(GraphQLType type) This will return the type in graphql SDL format, eg [typeName!]!static GraphQLUnmodifiedType
unwrapAll
(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 GraphQLType
unwrapNonNull
(GraphQLType type) Unwraps all non nullable layers of the type until it reaches a type that is notGraphQLNonNull
static <T extends GraphQLType>
TunwrapNonNullAs
(GraphQLType type) Unwraps all non nullable layers of the type until it reaches a type that is notGraphQLNonNull
and then cast to the target type.static GraphQLType
unwrapOne
(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 inGraphQLNonNull
andGraphQLList
type 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 notGraphQLNonNull
and 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 inGraphQLNonNull
andGraphQLList
type 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
-