Class: GraphQL::Language::Nodes::InlineFragment
Overview
An unnamed fragment, defined directly in the query with ... { }
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(type: nil, directives: NO_CHILDREN, selections: NO_CHILDREN, line: nil, col: nil, pos: nil, filename: nil, source: nil) ⇒ InlineFragment
constructor
: (?type: untyped, ?directives: Array, ?selections: Array[Field | FragmentSpread | InlineFragment], ?line: Integer?, ?col: Integer?, ?pos: Integer?, ?filename: String?, ?source: untyped) -> 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(type: nil, directives: NO_CHILDREN, selections: NO_CHILDREN, line: nil, col: nil, pos: nil, filename: nil, source: nil) ⇒ InlineFragment
: (?type: untyped, ?directives: Array, ?selections: Array[Field | FragmentSpread | InlineFragment], ?line: Integer?, ?col: Integer?, ?pos: Integer?, ?filename: String?, ?source: untyped) -> void
796
797
798
799
800
801
802
803
804
805
|
# File 'lib/graphql/language/nodes.rb', line 796
def initialize(type: nil, directives: NO_CHILDREN, selections: NO_CHILDREN, line: nil, col: nil, pos: nil, filename: nil, source: nil)
@line = line
@col = col
@pos = pos
@filename = filename
@source = source
@type = type
@directives = directives.freeze
@selections = selections.freeze
end
|
Instance Attribute Details
#directives ⇒ Object
769
770
771
|
# File 'lib/graphql/language/nodes.rb', line 769
def directives
@directives
end
|
#selections ⇒ Object
: Array[Field | FragmentSpread | InlineFragment]
771
772
773
|
# File 'lib/graphql/language/nodes.rb', line 771
def selections
@selections
end
|
#type ⇒ Object
Returns
TypeName, nil — Name of the type this fragment applies to, or nil if this fragment applies to any type
: TypeName?
762
763
764
|
# File 'lib/graphql/language/nodes.rb', line 762
def type
@type
end
|
Class Method Details
.from_a(filename, line, col, type, directives, selections, comment: nil) ⇒ Object
807
808
809
|
# File 'lib/graphql/language/nodes.rb', line 807
def self.from_a(filename, line, col, type, directives, selections, comment: nil)
self.new(filename: filename, line: line, col: col, type: type, directives: directives, selections: selections)
end
|
Instance Method Details
#children ⇒ Object
781
782
783
784
785
786
787
788
789
790
791
792
793
|
# File 'lib/graphql/language/nodes.rb', line 781
def children
@children ||= begin
if !@directives.empty? || !@selections.empty?
new_children = []
new_children.concat(@directives)
new_children.concat(@selections)
new_children.freeze
new_children
else
NO_CHILDREN
end
end
end
|
#marshal_dump ⇒ Object
811
812
813
814
815
816
817
818
819
|
# File 'lib/graphql/language/nodes.rb', line 811
def marshal_dump
[
line, col, @filename,
@type,
@directives,
@selections,
]
end
|
#marshal_load(values) ⇒ Object
821
822
823
|
# File 'lib/graphql/language/nodes.rb', line 821
def marshal_load(values)
@line, @col, @filename, @type, @directives, @selections = values
end
|
#merge_directive(**node_opts) ⇒ Object
773
774
775
|
# File 'lib/graphql/language/nodes.rb', line 773
def merge_directive(**node_opts)
merge(directives: directives + [GraphQL::Language::Nodes::Directive.new(**node_opts)])
end
|
#merge_selection(**node_opts) ⇒ Object
777
778
779
|
# File 'lib/graphql/language/nodes.rb', line 777
def merge_selection(**node_opts)
merge(selections: selections + [GraphQL::Language::Nodes::Field.new(**node_opts)])
end
|
#scalars ⇒ Object
764
765
766
|
# File 'lib/graphql/language/nodes.rb', line 764
def scalars
@scalars ||= [@type].freeze
end
|
#visit_method ⇒ Object
754
755
756
|
# File 'lib/graphql/language/nodes.rb', line 754
def visit_method
:on_inline_fragment
end
|