Class: GraphWeaver::Codegen::UnionRefNode

Inherits:
Node
  • Object
show all
Defined in:
lib/graph_weaver/codegen/nodes.rb

Overview

A reference to a union hoisted into the shared unions module (a named shared fragment spread as a whole union field): the query references ::Type and dispatches through .from_h, where is the alias the query module gives GraphQLUnions::. The type family lives once in the shared module, so the same union across queries is one Ruby type — nested is nil, nothing is emitted here.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Node

#coerce?, #hash_coerce_identity?, #identity?, #nested, #non_null?, #prop_type, #serialize_identity?

Constructor Details

#initialize(class_name) ⇒ UnionRefNode

Returns a new instance of UnionRefNode.



293
294
295
# File 'lib/graph_weaver/codegen/nodes.rb', line 293

def initialize(class_name)
  @class_name = class_name
end

Instance Attribute Details

#class_nameObject (readonly)

Returns the value of attribute class_name.



291
292
293
# File 'lib/graph_weaver/codegen/nodes.rb', line 291

def class_name
  @class_name
end

Instance Method Details

#bare_typeObject



297
# File 'lib/graph_weaver/codegen/nodes.rb', line 297

def bare_type = "#{class_name}::Type"

#cast(expr, _depth) ⇒ Object



299
300
301
# File 'lib/graph_weaver/codegen/nodes.rb', line 299

def cast(expr, _depth)
  "#{class_name}.from_h(#{expr})"
end