Overview
TheRails::GraphQL::Type class is the foundational object for all GraphQL types in the Rails GraphQL framework. Any schema definition extends from this class.
Namespace: Rails::GraphQL
Extends:
ActiveSupport::AutoloadHelpers::WithDirectivesHelpers::WithGlobalIDHelpers::Registerable
Type Kinds
The following type kinds are available:['Scalar', 'Object', 'Interface', 'Union', 'Enum', 'Input']Type::Scalar- Leaf types representing primitive valuesType::Object- Object types with fieldsType::Interface- Abstract types implemented by objectsType::Union- Types representing one of several object typesType::Enum- Enumeration types with predefined valuesType::Input- Input object types for arguments
Class Attributes
Identifies what methods are available to work as resolvers
Class Methods
base_type
Returns the base type class. Will be one of the classes defined inType::KINDS.
Returns: Class - One of Scalar, Object, Interface, Union, Enum, or Input
kind
Return the base type as a symbol. Returns:Symbol - :scalar, :object, :interface, :union, :enum, or :input
kind_enum
Return the specific value for the__TypeKind enum of this class.
Returns: String - Uppercase kind name
input_type?
Check if the current type is a valid input type. Returns:Boolean
output_type?
Check if the current type is a valid output type. Returns:Boolean
leaf_type?
Check if the current type is a leaf output type (Scalar or Enum). Returns:Boolean
operational?
Check if the object is a source of operations (Query, Mutation, Subscription). Returns:Boolean
=~
Check if another type is equivalent or a subclass.Type or instance to compare
Boolean
Alias: of_type?
decorate
Helper to instantiate the type if necessary.Value to potentially decorate
find_by_gid
Find and optionally instantiate a type by its Global ID.The Global ID object
create!
Dynamically create a new type using the Creator.The schema creating the type
Name of the type
Parent class (defaults to self)
Additional options
Configuration block
to_gql_backtrace
Generate a summarized representation for backtraces. Returns:String
Type Check Methods
Each type kind has a corresponding question method:Instance Methods
gql_base_type
Delegates to class methodbase_type.
Returns: Base type class
gql_kind
Delegates to class methodkind.
Returns: Symbol
gql_kind_enum
Delegates to class methodkind_enum.
Returns: String
gql_input_type?
Delegates to class methodinput_type?.
Returns: Boolean
gql_output_type?
Delegates to class methodoutput_type?.
Returns: Boolean
gql_leaf_type?
Delegates to class methodleaf_type?.
Returns: Boolean
Protected Methods
setup!
Provide setup options for child classes. Called internally during type creation.The kind of type
Whether this is a leaf type
Whether this is an input type
Whether this is an output type
valid_token?
Check if a value is a valid parser token.Value to check
Token type to validate against
Boolean