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 collapse

NONE =
[].freeze

Constants inherited from AbstractNode

AbstractNode::NO_CHILDREN

Instance Attribute Summary collapse

Attributes inherited from AbstractNode

#col, #filename, #line

Instance Method Summary collapse

Methods inherited from AbstractNode

#children, #delete_child, #eql?, inherited, #initialize, #initialize_copy, #merge, #position, #replace_child, #scalars, #to_query_string, #visit_method

Constructor Details

This class inherits a constructor from GraphQL::Language::Nodes::AbstractNode

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)



366
367
368
369
370
371
372
373
# File 'lib/graphql/language/nodes.rb', line 366

def initialize_node(attributes)
  @name = attributes[:name]
  @arguments = attributes[:arguments] || NONE
  @directives = attributes[:directives] || NONE
  @selections = attributes[:selections] || NONE
  # oops, alias is a keyword:
  @alias = attributes[:alias]
end

Instance Method Details

#children_method_nameObject

Override this because default is :fields



376
377
378
# File 'lib/graphql/language/nodes.rb', line 376

def children_method_name
  :selections
end

#initialize_node(attributes) ⇒ Object



366
367
368
369
370
371
372
373
# File 'lib/graphql/language/nodes.rb', line 366

def initialize_node(attributes)
  @name = attributes[:name]
  @arguments = attributes[:arguments] || NONE
  @directives = attributes[:directives] || NONE
  @selections = attributes[:selections] || NONE
  # oops, alias is a keyword:
  @alias = attributes[:alias]
end