Class: GraphQL::BaseType

Inherits:
Object
  • Object
show all
Includes:
DefinitionHelpers::DefinedByConfig, DefinitionHelpers::NonNullWithBang
Defined in:
lib/graphql/base_type.rb

Overview

The parent for all type classes.

Defined Under Namespace

Modules: HasPossibleTypes, ModifiesAnotherType Classes: Printer

Instance Method Summary collapse

Methods included from DefinitionHelpers::DefinedByConfig

included

Methods included from DefinitionHelpers::NonNullWithBang

#!

Instance Method Details

#==(other) ⇒ Boolean

Returns are these types equivalent? (incl. non-null, list).

Parameters:

Returns:

  • (Boolean) —

    are these types equivalent? (incl. non-null, list)



9
10
11
12
13
14
15
# File 'lib/graphql/base_type.rb', line 9

def ==(other)
  if other.is_a?(GraphQL::BaseType)
    self.to_s == other.to_s
  else
    super
  end
end

#resolve_type(value) ⇒ Object

Find out which possible type to use for value. Returns self if there are no possible types (ie, not Union or Interface)



31
32
33
# File 'lib/graphql/base_type.rb', line 31

def resolve_type(value)
  self
end

#to_s ⇒ Object Also known as: inspect

Print the human-readable name of this type



63
64
65
# File 'lib/graphql/base_type.rb', line 63

def to_s
  Printer.instance.print(self)
end

#unwrap ⇒ Object

If this type is modifying an underlying type, return the underlying type. (Otherwise, return self.)



19
20
21
# File 'lib/graphql/base_type.rb', line 19

def unwrap
  self
end