Class: GraphQL::Language::Nodes::Argument

Inherits:
AbstractNode show all
Defined in:
lib/graphql/language/nodes.rb

Overview

A key-value pair for a field's inputs

Constant Summary

Constants inherited from AbstractNode

GraphQL::Language::Nodes::AbstractNode::NO_CHILDREN

Instance Attribute Summary collapse

Attributes inherited from AbstractNode

#filename

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from AbstractNode

#==, #children_method_name, children_of_type, #col, #definition_line, #delete_child, inherited, #initialize_copy, #line, #merge, #position, #replace_child, #to_query_string

Constructor Details

#initialize(name: nil, value: nil, line: nil, col: nil, pos: nil, filename: nil, source: nil) ⇒ Argument

: (?name: untyped, ?value: untyped, ?line: Integer?, ?col: Integer?, ?pos: Integer?, ?filename: String?, ?source: untyped) -> void



338
339
340
341
342
343
344
345
346
# File 'lib/graphql/language/nodes.rb', line 338

def initialize(name: nil, value: nil, line: nil, col: nil, pos: nil, filename: nil, source: nil)
  @line = line
  @col = col
  @pos = pos
  @filename = filename
  @source = source
  @name = name
  @value = value
end

Instance Attribute Details

#name ⇒ Object (readonly)

Returns

  • String — the key for this argument : String


325
326
327
# File 'lib/graphql/language/nodes.rb', line 325

def name
  @name
end

#value ⇒ Object (readonly)

Returns

  • String, Float, Integer, Boolean, Array, InputObject, VariableIdentifier, Enum, NullValue — The value passed for this key : untyped


331
332
333
# File 'lib/graphql/language/nodes.rb', line 331

def value
  @value
end

Class Method Details

.from_a(filename, line, col, name, value, comment: nil) ⇒ Object



348
349
350
# File 'lib/graphql/language/nodes.rb', line 348

def self.from_a(filename, line, col, name, value, comment: nil)
  self.new(filename: filename, line: line, col: col, name: name, value: value)
end

Instance Method Details

#children ⇒ Object



367
368
369
# File 'lib/graphql/language/nodes.rb', line 367

def children
  @children ||= Array(value).flatten.tap { _1.select! { |v| v.is_a?(AbstractNode) } }
end

#marshal_dump ⇒ Object



352
353
354
355
356
357
358
359
# File 'lib/graphql/language/nodes.rb', line 352

def marshal_dump
  [
    line, col, # use methods here to force them to be calculated
    @filename,
    @name,
    @value,
  ]
end

#marshal_load(values) ⇒ Object



361
362
363
# File 'lib/graphql/language/nodes.rb', line 361

def marshal_load(values)
  @line, @col, @filename, @name, @value = values
end

#scalars ⇒ Object



333
334
335
# File 'lib/graphql/language/nodes.rb', line 333

def scalars
  @scalars ||= [@name, @value].freeze
end

#visit_method ⇒ Object



317
318
319
# File 'lib/graphql/language/nodes.rb', line 317

def visit_method
  :on_argument
end