Class: GraphQL::Language::Nodes::FragmentDefinition
Overview
A reusable fragment, defined at document-level.
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
-
#children ⇒ Object
-
#initialize(name: nil, type: nil, directives: NONE, selections: NONE, filename: nil, pos: nil, source: nil, line: nil, col: nil) ⇒ FragmentDefinition
constructor
: (?name: untyped, ?type: untyped, ?directives: Array, ?selections: Array[Field | FragmentSpread | InlineFragment], ?filename: String?, ?pos: Integer?, ?source: untyped, ?line: Integer?, ?col: Integer?) -> void.
-
#marshal_dump ⇒ Object
-
#marshal_load(values) ⇒ Object
-
#merge_directive(**node_opts) ⇒ Object
-
#merge_selection(**node_opts) ⇒ Object
-
#scalars ⇒ Object
-
#visit_method ⇒ Object
#==, #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, type: nil, directives: NONE, selections: NONE, filename: nil, pos: nil, source: nil, line: nil, col: nil) ⇒ FragmentDefinition
: (?name: untyped, ?type: untyped, ?directives: Array, ?selections: Array[Field | FragmentSpread | InlineFragment], ?filename: String?, ?pos: Integer?, ?source: untyped, ?line: Integer?, ?col: Integer?) -> void
624
625
626
627
628
629
630
631
632
633
634
|
# File 'lib/graphql/language/nodes.rb', line 624
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
|
Instance Attribute Details
#directives ⇒ Object
660
661
662
|
# File 'lib/graphql/language/nodes.rb', line 660
def directives
@directives
end
|
#name ⇒ Object
649
650
651
|
# File 'lib/graphql/language/nodes.rb', line 649
def name
@name
end
|
#selections ⇒ Object
: Array[Field | FragmentSpread | InlineFragment]
658
659
660
|
# File 'lib/graphql/language/nodes.rb', line 658
def selections
@selections
end
|
#type ⇒ Object
651
652
653
|
# File 'lib/graphql/language/nodes.rb', line 651
def type
@type
end
|
Class Method Details
.from_a(filename, line, col, name, type, directives, selections) ⇒ Object
636
637
638
|
# File 'lib/graphql/language/nodes.rb', line 636
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
|
Instance Method Details
#children ⇒ Object
670
671
672
673
674
675
676
677
678
679
680
681
682
|
# File 'lib/graphql/language/nodes.rb', line 670
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
|
#marshal_dump ⇒ Object
640
641
642
|
# File 'lib/graphql/language/nodes.rb', line 640
def marshal_dump
[line, col, @filename, @name, @type, @directives, @selections]
end
|
#marshal_load(values) ⇒ Object
644
645
646
|
# File 'lib/graphql/language/nodes.rb', line 644
def marshal_load(values)
@line, @col, @filename, @name, @type, @directives, @selections = values
end
|
#merge_directive(**node_opts) ⇒ Object
666
667
668
|
# File 'lib/graphql/language/nodes.rb', line 666
def merge_directive(**node_opts)
merge(directives: directives + [GraphQL::Language::Nodes::Directive.new(**node_opts)])
end
|
#merge_selection(**node_opts) ⇒ Object
662
663
664
|
# File 'lib/graphql/language/nodes.rb', line 662
def merge_selection(**node_opts)
merge(selections: selections + [GraphQL::Language::Nodes::Field.new(**node_opts)])
end
|
#scalars ⇒ Object
653
654
655
|
# File 'lib/graphql/language/nodes.rb', line 653
def scalars
@scalars ||= [@name, @type].freeze
end
|
#visit_method ⇒ Object
619
620
621
|
# File 'lib/graphql/language/nodes.rb', line 619
def visit_method
:on_fragment_definition
end
|