Class: GraphQL::TypeKinds::TypeKind

Inherits:
Object
  • Object
show all
Defined in:
lib/graph_ql/type_kinds.rb,
lib/graph_ql/type_kinds.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, resolves: false, fields: false, wraps: false, input: false) ⇒ TypeKind

Returns a new instance of TypeKind.



4
5
6
7
8
9
10
11
# File 'lib/graph_ql/type_kinds.rb', line 4

def initialize(name, resolves: false, fields: false, wraps: false, input: false)
  @name = name
  @resolves = resolves
  @fields = fields
  @wraps = wraps
  @input = input
  @composite = fields? || resolves?
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/graph_ql/type_kinds.rb', line 3

def name
  @name
end

Instance Method Details

#composite?Boolean

Returns:

  • (Boolean)


18
# File 'lib/graph_ql/type_kinds.rb', line 18

def composite?; @composite; end

#fields?Boolean

Returns:

  • (Boolean)


14
# File 'lib/graph_ql/type_kinds.rb', line 14

def fields?;    @fields;    end

#input?Boolean

Returns:

  • (Boolean)


16
# File 'lib/graph_ql/type_kinds.rb', line 16

def input?;     @input;     end

#resolve(type, value) ⇒ Object



20
21
22
23
24
25
26
# File 'lib/graph_ql/type_kinds.rb', line 20

def resolve(type, value)
  if resolves?
    type.resolve_type(value)
  else
    type
  end
end

#resolves?Boolean

Returns:

  • (Boolean)


13
# File 'lib/graph_ql/type_kinds.rb', line 13

def resolves?;  @resolves;  end

#to_sObject



17
# File 'lib/graph_ql/type_kinds.rb', line 17

def to_s;       @name;      end

#unwrap(type) ⇒ Object



28
29
30
31
32
33
34
35
# File 'lib/graph_ql/type_kinds.rb', line 28

def unwrap(type)
  if wraps?
    wrapped_type = type.of_type
    wrapped_type.kind.unwrap(wrapped_type)
  else
    type
  end
end

#wraps?Boolean

Returns:

  • (Boolean)


15
# File 'lib/graph_ql/type_kinds.rb', line 15

def wraps?;     @wraps;     end