Class: GraphQL::Language::Nodes::Field

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

Overview

A single selection in a GraphQL query.

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, #children_method_name, children_of_type, #col, #definition_line, #delete_child, inherited, #initialize_copy, #line, #merge, #position, #replace_child, #scalars, #to_query_string

Constructor Details

#initialize(name: nil, arguments: NONE, directives: NONE, selections: NONE, field_alias: nil, line: nil, col: nil, pos: nil, filename: nil, source: nil) ⇒ Field

Returns a new instance of Field.



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

def initialize(name: nil, arguments: NONE, directives: NONE, selections: NONE, field_alias: nil, line: nil, col: nil, pos: nil, filename: nil, source: nil)
  @name = name
  @arguments = arguments || NONE
  @directives = directives || NONE
  @selections = selections || NONE
  # oops, alias is a keyword:
  @alias = field_alias
  @line = line
  @col = col
  @pos = pos
  @filename = filename
  @source = source
end

Instance Attribute Details

#selectionsArray<Nodes::Field>

Returns Selections on this object (or empty array if this is a scalar field).

Returns:

  • (Array<Nodes::Field>)

    Selections on this object (or empty array if this is a scalar field)



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

def initialize(name: nil, arguments: NONE, directives: NONE, selections: NONE, field_alias: nil, line: nil, col: nil, pos: nil, filename: nil, source: nil)
  @name = name
  @arguments = arguments || NONE
  @directives = directives || NONE
  @selections = selections || NONE
  # oops, alias is a keyword:
  @alias = field_alias
  @line = line
  @col = col
  @pos = pos
  @filename = filename
  @source = source
end

Class Method Details

.from_a(filename, line, col, field_alias, name, arguments, directives, selections) ⇒ Object

rubocop:disable Metrics/ParameterLists



419
420
421
# File 'lib/graphql/language/nodes.rb', line 419

def self.from_a(filename, line, col, field_alias, name, arguments, directives, selections) # rubocop:disable Metrics/ParameterLists
  self.new(filename: filename, line: line, col: col, field_alias: field_alias, name: name, arguments: arguments, directives: directives, selections: selections)
end

Instance Method Details

#marshal_dumpObject



423
424
425
# File 'lib/graphql/language/nodes.rb', line 423

def marshal_dump
  [line, col, @filename, @name, @arguments, @directives, @selections, @alias]
end

#marshal_load(values) ⇒ Object



427
428
429
# File 'lib/graphql/language/nodes.rb', line 427

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