class GraphQL::Language::Nodes::OperationDefinition
A query, mutation or subscription. May be anonymous or named. May be explicitly typed (eg mutation { ... }) or implicitly a query (eg { ... }).
Attributes
directives
[R]
Array[Directive]
Returns
-
String— The root type for this operation:"query"(including implicit queries),"mutation"or"subscription"
selections
[R]
Array[Field | FragmentSpread | InlineFragment]
Returns
-
Array<Field, FragmentSpread, InlineFragment>— Root-level fields on this operation
variables
[R]
Array[VariableDefinition]
Returns
-
Array<VariableDefinition>— Variable $definitions for this operation
Public Class Methods
Source
# File lib/graphql/language/nodes.rb, line 1087 def self.from_a(filename, line, col, operation_type, name, variables, directives, selections, comment: nil) # rubocop:disable Metrics/ParameterLists self.new(filename: filename, line: line, col: col, operation_type: operation_type, name: name, variables: variables, directives: directives, selections: selections) end
(?operation_type: untyped, ?name: untyped, ?variables: Array[VariableDefinition], ?directives: Array[Directive], ?selections: Array[Field | FragmentSpread | InlineFragment], ?line: Integer?, ?col: Integer?, ?pos: Integer?, ?filename: String?, ?source: untyped, ?definition_pos: Integer?) → void
Source
# File lib/graphql/language/nodes.rb, line 1073 def initialize(operation_type: nil, name: nil, variables: NO_CHILDREN, directives: NO_CHILDREN, selections: NO_CHILDREN, line: nil, col: nil, pos: nil, filename: nil, source: nil, definition_pos: nil) @line = line @col = col @pos = pos @filename = filename @source = source @operation_type = operation_type @name = name @variables = variables.freeze @directives = directives.freeze @selections = selections.freeze @definition_pos = definition_pos end
Public Instance Methods
Source
# File lib/graphql/language/nodes.rb, line 1057 def children @children ||= begin if !@variables.empty? || !@directives.empty? || !@selections.empty? new_children = [] new_children.concat(@variables) new_children.concat(@directives) new_children.concat(@selections) new_children.freeze new_children else NO_CHILDREN end end end
Source
# File lib/graphql/language/nodes.rb, line 1091 def marshal_dump [ line, col, # use methods here to force them to be calculated @filename, @operation_type, @name, @variables, @directives, @selections, ] end
Source
# File lib/graphql/language/nodes.rb, line 1103 def marshal_load(values) @line, @col, @filename, @operation_type, @name, @variables, @directives, @selections = values end
# File lib/graphql/language/nodes.rb, line 1049 def merge_directive(**node_opts) merge(directives: directives + [GraphQL::Language::Nodes::Directive.new(**node_opts)]) end
# File lib/graphql/language/nodes.rb, line 1053 def merge_selection(**node_opts) merge(selections: selections + [GraphQL::Language::Nodes::Field.new(**node_opts)]) end
Source
# File lib/graphql/language/nodes.rb, line 1045 def merge_variable(**node_opts) merge(variables: variables + [GraphQL::Language::Nodes::VariableDefinition.new(**node_opts)]) end
Source
# File lib/graphql/language/nodes.rb, line 1027 def scalars @scalars ||= [@operation_type, @name].freeze end
Source
# File lib/graphql/language/nodes.rb, line 1011 def visit_method :on_operation_definition end