Class: GraphQL::Language::Nodes::FragmentSpread

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

Overview

Application of a named fragment in a selection

Constant Summary

Constants inherited from AbstractNode

AbstractNode::NO_CHILDREN

Instance Attribute Summary collapse

Attributes inherited from AbstractNode

#filename

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from AbstractNode

#==, #children_method_name, children_of_type, #col, #definition_line, #delete_child, inherited, #initialize_copy, #line, #merge, #position, #replace_child, #to_query_string

Constructor Details

#initialize(name: nil, directives: NO_CHILDREN, line: nil, col: nil, pos: nil, filename: nil, source: nil) ⇒ FragmentSpread

: (?name: untyped, ?directives: Array, ?line: Integer?, ?col: Integer?, ?pos: Integer?, ?filename: String?, ?source: untyped) -> void



718
719
720
721
722
723
724
725
726
# File 'lib/graphql/language/nodes.rb', line 718

def initialize(name: nil, directives: NO_CHILDREN, line: nil, col: nil, pos: nil, filename: nil, source: nil)
  @line = line
  @col = col
  @pos = pos
  @filename = filename
  @source = source
  @name = name
  @directives = directives.freeze
end

Instance Attribute Details

#directives ⇒ Object (readonly) Also known as: children

: Array



709
710
711
# File 'lib/graphql/language/nodes.rb', line 709

def directives
  @directives
end

#name ⇒ Object (readonly)

Returns



702
703
704
# File 'lib/graphql/language/nodes.rb', line 702

def name
  @name
end

Class Method Details

.from_a(filename, line, col, name, directives, comment: nil) ⇒ Object



728
729
730
# File 'lib/graphql/language/nodes.rb', line 728

def self.from_a(filename, line, col, name, directives, comment: nil)
  self.new(filename: filename, line: line, col: col, name: name, directives: directives)
end

Instance Method Details

#marshal_dump ⇒ Object



732
733
734
735
736
737
738
739
# File 'lib/graphql/language/nodes.rb', line 732

def marshal_dump
  [
    line, col, # use methods here to force them to be calculated
    @filename,
    @name,
    @directives,
  ]
end

#marshal_load(values) ⇒ Object



741
742
743
# File 'lib/graphql/language/nodes.rb', line 741

def marshal_load(values)
  @line, @col, @filename, @name, @directives = values
end

#merge_directive(**node_opts) ⇒ Object



711
712
713
# File 'lib/graphql/language/nodes.rb', line 711

def merge_directive(**node_opts)
  merge(directives: directives + [GraphQL::Language::Nodes::Directive.new(**node_opts)])
end

#scalars ⇒ Object



704
705
706
# File 'lib/graphql/language/nodes.rb', line 704

def scalars
  @scalars ||= [@name].freeze
end

#visit_method ⇒ Object



694
695
696
# File 'lib/graphql/language/nodes.rb', line 694

def visit_method
  :on_fragment_spread
end