class GraphQL::Language::Nodes::Field
A single selection in a GraphQL query.
Attributes
arguments
[R]
Array[Argument]
directives
[R]
Array[Directive]
selections
[R]
Array[Field | FragmentSpread | InlineFragment]
Public Class Methods
# File lib/graphql/language/nodes.rb, line 551 def self.from_a(filename, line, col, field_alias, name, arguments, directives, selections) # rubocop:disable Metrics/ParameterLists self.new(filename: filename, line: line, col: col, field_alias: field_alias, name: name, arguments: arguments, directives: directives, selections: selections) end
(?name: untyped, ?arguments: Array[Argument]?, ?directives: Array[Directive]?, ?selections: (Array[Field | FragmentSpread | InlineFragment])?, ?field_alias: String?, ?line: Integer?, ?col: Integer?, ?pos: Integer?, ?filename: String?, ?source: untyped) → void
Source
# File lib/graphql/language/nodes.rb, line 537 def initialize(name: nil, arguments: NONE, directives: NONE, selections: NONE, field_alias: nil, line: nil, col: nil, pos: nil, filename: nil, source: nil) @name = name @arguments = arguments || NONE @directives = directives || NONE @selections = selections || NONE # oops, alias is a keyword: @alias = field_alias @line = line @col = col @pos = pos @filename = filename @source = source end
Public Instance Methods
Source
# File lib/graphql/language/nodes.rb, line 591 def children @children ||= begin if !@arguments.empty? || !@selections.empty? || !@directives.empty? new_children = [] new_children.concat(@arguments) new_children.concat(@selections) new_children.concat(@directives) new_children.freeze new_children else NO_CHILDREN end end end
Source
# File lib/graphql/language/nodes.rb, line 555 def marshal_dump [line, col, @filename, @name, @arguments, @directives, @selections, @alias] end
Source
# File lib/graphql/language/nodes.rb, line 559 def marshal_load(values) @line, @col, @filename, @name, @arguments, @directives, @selections, @alias = values end
Source
# File lib/graphql/language/nodes.rb, line 579 def merge_argument(**node_opts) merge(arguments: arguments + [GraphQL::Language::Nodes::Argument.new(**node_opts)]) end
# File lib/graphql/language/nodes.rb, line 587 def merge_directive(**node_opts) merge(directives: directives + [GraphQL::Language::Nodes::Directive.new(**node_opts)]) end
# File lib/graphql/language/nodes.rb, line 583 def merge_selection(**node_opts) merge(selections: selections + [GraphQL::Language::Nodes::Field.new(**node_opts)]) end
Source
# File lib/graphql/language/nodes.rb, line 568 def scalars @scalars ||= [@name, @alias].freeze end
Source
# File lib/graphql/language/nodes.rb, line 532 def visit_method :on_field end