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.



289
290
291
# File 'lib/graph_weaver/codegen/nodes.rb', line 289

def initialize(class_name)
  @class_name = class_name
end

Instance Attribute Details

#class_name ⇒ Object (readonly)

Returns the value of attribute class_name.



287
288
289
# File 'lib/graph_weaver/codegen/nodes.rb', line 287

def class_name
  @class_name
end

Instance Method Details

#bare_type ⇒ Object



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

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

#cast(expr, _depth) ⇒ Object



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

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