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) ⇒ TypeKind

Returns a new instance of TypeKind.



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

def initialize(name, resolves: false, fields: false, wraps: false)
  @name = name
  @resolves = resolves
  @fields = fields
  @wraps = wraps
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

#fields?Boolean

Returns:

  • (Boolean)


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

def fields?;    @fields;    end

#resolve(type, value) ⇒ Object



16
17
18
19
20
21
22
# File 'lib/graph_ql/type_kinds.rb', line 16

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

#resolves?Boolean

Returns:

  • (Boolean)


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

def resolves?;  @resolves;  end

#to_sObject



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

def to_s;       @name;      end

#unwrap(type) ⇒ Object



24
25
26
27
28
29
30
31
# File 'lib/graph_ql/type_kinds.rb', line 24

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

#wraps?Boolean

Returns:

  • (Boolean)


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

def wraps?;     @wraps;     end