Class: GraphWeaver::Codegen::ObjectNode

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

Defined Under Namespace

Classes: Field

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(class_name) ⇒ ObjectNode

Returns a new instance of ObjectNode.



148
149
150
151
152
# File 'lib/graph_weaver/codegen/nodes.rb', line 148

def initialize(class_name)
  @class_name = class_name
  @fields = []
  @mixins = []
end

Instance Attribute Details

#class_name ⇒ Object (readonly)

Returns the value of attribute class_name.



143
144
145
# File 'lib/graph_weaver/codegen/nodes.rb', line 143

def class_name
  @class_name
end

#fields ⇒ Object (readonly)

Returns the value of attribute fields.



143
144
145
# File 'lib/graph_weaver/codegen/nodes.rb', line 143

def fields
  @fields
end

#graphql_type ⇒ Object

the GraphQL type this struct was generated from, and any registered helper modules to include (see Codegen.register_type)



146
147
148
# File 'lib/graph_weaver/codegen/nodes.rb', line 146

def graphql_type
  @graphql_type
end

#mixins ⇒ Object

the GraphQL type this struct was generated from, and any registered helper modules to include (see Codegen.register_type)



146
147
148
# File 'lib/graph_weaver/codegen/nodes.rb', line 146

def mixins
  @mixins
end

Instance Method Details

#bare_type ⇒ Object



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

def bare_type = class_name

#cast(expr, _depth) ⇒ Object



160
161
162
# File 'lib/graph_weaver/codegen/nodes.rb', line 160

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

#identity? ⇒ Boolean

Returns:

  • (Boolean)


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

def identity? = false

#nested ⇒ Object



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

def nested = self

#non_null? ⇒ Boolean

Returns:

  • (Boolean)


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

def non_null? = false

#prop_type ⇒ Object



156
157
158
# File 'lib/graph_weaver/codegen/nodes.rb', line 156

def prop_type
  "T.nilable(#{bare_type})"
end