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

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

Overview

A single selection in a GraphQL query.

Instance Attribute Summary collapse

Attributes inherited from AbstractNode

#col, #filename, #line

Instance Method Summary collapse

Methods inherited from AbstractNode

#eql?, #initialize, #position, #to_query_string

Constructor Details

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

Instance Attribute Details

#aliasObject

Returns the value of attribute alias



188
189
190
# File 'lib/graphql/language/nodes.rb', line 188

def alias
  @alias
end

#argumentsObject

Returns the value of attribute arguments



188
189
190
# File 'lib/graphql/language/nodes.rb', line 188

def arguments
  @arguments
end

#directivesObject

Returns the value of attribute directives



188
189
190
# File 'lib/graphql/language/nodes.rb', line 188

def directives
  @directives
end

#nameObject

Returns the value of attribute name



188
189
190
# File 'lib/graphql/language/nodes.rb', line 188

def name
  @name
end

#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)



193
194
195
# File 'lib/graphql/language/nodes.rb', line 193

def selections
  @selections
end

Instance Method Details

#childrenObject



206
207
208
# File 'lib/graphql/language/nodes.rb', line 206

def children
  arguments + directives + selections
end

#initialize_node(name: nil, arguments: [], directives: [], selections: [], **kwargs) ⇒ Object



193
194
195
196
197
198
199
200
# File 'lib/graphql/language/nodes.rb', line 193

def initialize_node(name: nil, arguments: [], directives: [], selections: [], **kwargs)
  @name = name
  # oops, alias is a keyword:
  @alias = kwargs.fetch(:alias, nil)
  @arguments = arguments
  @directives = directives
  @selections = selections
end

#scalarsObject



202
203
204
# File 'lib/graphql/language/nodes.rb', line 202

def scalars
  [name, self.alias]
end