Class GraphQLTypeUtil


  • @PublicApi
    public class GraphQLTypeUtil
    extends java.lang.Object
    A utility class that helps work with GraphQLTypes
    • Constructor Detail

      • GraphQLTypeUtil

        public GraphQLTypeUtil()
    • Method Detail

      • simplePrint

        public static java.lang.String simplePrint​(GraphQLType type)
        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!]!
      • isNonNull

        public static boolean isNonNull​(GraphQLType type)
        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

        public static boolean isNullable​(GraphQLType type)
        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

        public static boolean isList​(GraphQLType type)
        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

        public static boolean isWrapped​(GraphQLType type)
        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

        public static boolean isNotWrapped​(GraphQLType type)
        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

        public static boolean isScalar​(GraphQLType type)
        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

        public static boolean isEnum​(GraphQLType type)
        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

        public static boolean isLeaf​(GraphQLType type)
        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

        public static boolean isInput​(GraphQLType type)
        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

        public static GraphQLType unwrapOne​(GraphQLType type)
        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

        public static <T extends GraphQLType> T unwrapOneAs​(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.
        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

        public static GraphQLUnmodifiedType unwrapAll​(GraphQLType type)
        Unwraps all layers of the type or just returns the type again if it's not a wrapped type
        Parameters:
        type - the type to unwrapOne
        Returns:
        the underlying type
      • unwrapAllAs

        public static <T extends GraphQLType> T unwrapAllAs​(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.
        Type Parameters:
        T - for two
        Parameters:
        type - the type to unwrapOne
        Returns:
        the underlying type
      • unwrapNonNull

        public static GraphQLType unwrapNonNull​(GraphQLType type)
        Unwraps all non nullable layers of the type until it reaches a type that is not GraphQLNonNull
        Parameters:
        type - the type to unwrap
        Returns:
        the underlying type that is not GraphQLNonNull
      • unwrapNonNullAs

        public static <T extends GraphQLType> T unwrapNonNullAs​(GraphQLType type)
        Unwraps all non nullable layers of the type until it reaches a type that is not GraphQLNonNull 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

        public static java.util.Stack<GraphQLType> unwrapType​(GraphQLType type)
        graphql types can be wrapped in GraphQLNonNull and GraphQLList 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

        public static boolean isInterfaceOrUnion​(GraphQLType type)
      • isObjectType

        public static boolean isObjectType​(GraphQLType type)
      • isSystemElement

        public static java.util.function.Predicate<GraphQLNamedSchemaElement> 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