Class: GraphQL::Union

Inherits:
Object
  • Object
show all
Includes:
NonNullWithBang
Defined in:
lib/graph_ql/union.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from NonNullWithBang

#!

Constructor Details

#initialize(name, desc, types) ⇒ Union

Returns a new instance of Union.



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

def initialize(name, desc, types)
  @name = name
  @description = desc
  @possible_types = types
end

Instance Attribute Details

#descriptionObject (readonly)

Returns the value of attribute description.



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

def description
  @description
end

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

#possible_typesObject (readonly)

Returns the value of attribute possible_types.



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

def possible_types
  @possible_types
end

Instance Method Details

#kindObject



10
11
12
# File 'lib/graph_ql/union.rb', line 10

def kind
  GraphQL::TypeKinds::UNION
end

#resolve_type(object) ⇒ Object

Find a type in this union for a given object. Reimplement if needed



16
17
18
19
# File 'lib/graph_ql/union.rb', line 16

def resolve_type(object)
  type_name = object.class.name
  possible_types.find {|t| t.name == type_name}
end

#to_sObject



21
22
23
# File 'lib/graph_ql/union.rb', line 21

def to_s
  "<GraphQL::Union #{name}>"
end