Class: GraphQL::Language::Nodes::Directive

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

Constant Summary

Constants inherited from AbstractNode

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, arguments: NO_CHILDREN, line: nil, col: nil, pos: nil, filename: nil, source: nil) ⇒ Directive

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



394
395
396
397
398
399
400
401
402
# File 'lib/graphql/language/nodes.rb', line 394

def initialize(name: nil, arguments: NO_CHILDREN, line: nil, col: nil, pos: nil, filename: nil, source: nil)
  @line = line
  @col = col
  @pos = pos
  @filename = filename
  @source = source
  @name = name
  @arguments = arguments.freeze
end

Instance Attribute Details

#arguments ⇒ Object (readonly) Also known as: children

: Array



385
386
387
# File 'lib/graphql/language/nodes.rb', line 385

def arguments
  @arguments
end

#name ⇒ Object (readonly)

: String



378
379
380
# File 'lib/graphql/language/nodes.rb', line 378

def name
  @name
end

Class Method Details

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



404
405
406
# File 'lib/graphql/language/nodes.rb', line 404

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

Instance Method Details

#marshal_dump ⇒ Object



408
409
410
411
412
413
414
415
# File 'lib/graphql/language/nodes.rb', line 408

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

#marshal_load(values) ⇒ Object



417
418
419
# File 'lib/graphql/language/nodes.rb', line 417

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

#merge_argument(**node_opts) ⇒ Object



387
388
389
# File 'lib/graphql/language/nodes.rb', line 387

def merge_argument(**node_opts)
  merge(arguments: arguments + [GraphQL::Language::Nodes::Argument.new(**node_opts)])
end

#scalars ⇒ Object



380
381
382
# File 'lib/graphql/language/nodes.rb', line 380

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

#visit_method ⇒ Object



373
374
375
# File 'lib/graphql/language/nodes.rb', line 373

def visit_method
  :on_directive
end