Class: GraphQL::Language::Nodes::OperationDefinition

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

Overview

A query, mutation or subscription. May be anonymous or named. May be explicitly typed (eg mutation { ... }) or implicitly a query (eg { ... }).

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

#directivesObject

Returns the value of attribute directives



328
329
330
# File 'lib/graphql/language/nodes.rb', line 328

def directives
  @directives
end

#nameString?

Returns The name for this operation, or nil if unnamed

Returns:

  • (String, nil)

    The name for this operation, or nil if unnamed



342
343
344
# File 'lib/graphql/language/nodes.rb', line 342

def name
  @name
end

#operation_typeString?

Returns The root type for this operation, or nil for implicit "query"

Returns:

  • (String, nil)

    The root type for this operation, or nil for implicit "query"



336
337
338
# File 'lib/graphql/language/nodes.rb', line 336

def operation_type
  @operation_type
end

#selectionsArray<Field>

Returns Root-level fields on this operation

Returns:

  • (Array<Field>)

    Root-level fields on this operation



333
334
335
# File 'lib/graphql/language/nodes.rb', line 333

def selections
  @selections
end

#variablesArray<VariableDefinition>

Returns Variable definitions for this operation

Returns:



330
331
332
# File 'lib/graphql/language/nodes.rb', line 330

def variables
  @variables
end

Instance Method Details

#childrenObject



350
351
352
# File 'lib/graphql/language/nodes.rb', line 350

def children
  variables + directives + selections
end

#initialize_node(operation_type: nil, name: nil, variables: [], directives: [], selections: []) ⇒ Object



342
343
344
345
346
347
348
# File 'lib/graphql/language/nodes.rb', line 342

def initialize_node(operation_type: nil, name: nil, variables: [], directives: [], selections: [])
  @operation_type = operation_type
  @name = name
  @variables = variables
  @directives = directives
  @selections = selections
end

#scalarsObject



354
355
356
# File 'lib/graphql/language/nodes.rb', line 354

def scalars
  [operation_type, name]
end