class GraphQL::Language::Nodes::FragmentDefinition
A reusable fragment, defined at document-level.
Attributes
directives
[R]
Array[Directive]
selections
[R]
Array[Field | FragmentSpread | InlineFragment]
Public Class Methods
# File lib/graphql/language/nodes.rb, line 635 def self.from_a(filename, line, col, name, type, directives, selections) self.new(filename: filename, line: line, col: col, name: name, type: type, directives: directives, selections: selections) end
(?name: untyped, ?type: untyped, ?directives: Array[Directive], ?selections: Array[Field | FragmentSpread | InlineFragment], ?filename: String?, ?pos: Integer?, ?source: untyped, ?line: Integer?, ?col: Integer?) → void
Source
# File lib/graphql/language/nodes.rb, line 623 def initialize(name: nil, type: nil, directives: NONE, selections: NONE, filename: nil, pos: nil, source: nil, line: nil, col: nil) @name = name @type = type @directives = directives @selections = selections @filename = filename @pos = pos @source = source @line = line @col = col end
Public Instance Methods
Source
# File lib/graphql/language/nodes.rb, line 669 def children @children ||= begin if !@selections.empty? || !@directives.empty? new_children = [] 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 639 def marshal_dump [line, col, @filename, @name, @type, @directives, @selections] end
Source
# File lib/graphql/language/nodes.rb, line 643 def marshal_load(values) @line, @col, @filename, @name, @type, @directives, @selections = values end
# File lib/graphql/language/nodes.rb, line 665 def merge_directive(**node_opts) merge(directives: directives + [GraphQL::Language::Nodes::Directive.new(**node_opts)]) end
# File lib/graphql/language/nodes.rb, line 661 def merge_selection(**node_opts) merge(selections: selections + [GraphQL::Language::Nodes::Field.new(**node_opts)]) end
Source
# File lib/graphql/language/nodes.rb, line 652 def scalars @scalars ||= [@name, @type].freeze end
Source
# File lib/graphql/language/nodes.rb, line 618 def visit_method :on_fragment_definition end