class GraphQL::Language::Nodes::AbstractNode

{AbstractNode} is the base class for all nodes in a GraphQL AST.

It provides some APIs for working with ASTs:

Attributes

col[RW]
filename[RW]
line[RW]

Public Class Methods

new(options={}) click to toggle source

Initialize a node by extracting its position, then calling the class's `initialize_node` method. @param options [Hash] Initial attributes for this node

# File lib/graphql/language/nodes.rb, line 26
def initialize(options={})
  if options.key?(:position_source)
    position_source = options.delete(:position_source)
    @line, @col = position_source.line_and_column
  end

  @filename = options.delete(:filename)

  initialize_node(options)
end

Public Instance Methods

children() click to toggle source

@return [Array<GraphQL::Language::Nodes::AbstractNode>] all nodes in the tree below this one

# File lib/graphql/language/nodes.rb, line 52
def children
  []
end
eql?(other) click to toggle source

Value equality @return [Boolean] True if `self` is equivalent to `other`

# File lib/graphql/language/nodes.rb, line 44
def eql?(other)
  return true if equal?(other)
  other.is_a?(self.class) &&
    other.scalars.eql?(self.scalars) &&
    other.children.eql?(self.children)
end
initialize_node(options={}) click to toggle source

This is called with node-specific options

# File lib/graphql/language/nodes.rb, line 38
def initialize_node(options={})
  raise NotImplementedError
end
position() click to toggle source
# File lib/graphql/language/nodes.rb, line 61
def position
  [line, col]
end
scalars() click to toggle source

@return [Array<Integer, Float, String, Boolean, Array>] Scalar values attached to this node

# File lib/graphql/language/nodes.rb, line 57
def scalars
  []
end
to_query_string(printer: GraphQL::Language::Printer.new) click to toggle source
# File lib/graphql/language/nodes.rb, line 65
def to_query_string(printer: GraphQL::Language::Printer.new)
  printer.print(self)
end