Module: GraphQL::InternalRepresentation::Visit
- Defined in:
- lib/graphql/internal_representation/visit.rb
Overview
Traverse a re-written query tree, calling handlers for each node
Class Method Summary collapse
-
.each_node(node) {|node| ... } ⇒ Object
Traverse a node in a rewritten query tree, visiting the node itself and each of its typed children.
-
.visit_each_node(operations, handlers) ⇒ Object
Class Method Details
.each_node(node) {|node| ... } ⇒ Object
Traverse a node in a rewritten query tree, visiting the node itself and each of its typed children.
26 27 28 29 30 31 32 33 |
# File 'lib/graphql/internal_representation/visit.rb', line 26 def each_node(node) yield(node) node.typed_children.each do |obj_type, children| children.each do |name, node| each_node(node) { |n| yield(n) } end end end |
.visit_each_node(operations, handlers) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/graphql/internal_representation/visit.rb', line 7 def visit_each_node(operations, handlers) return if handlers.empty? # Post-validation: make some assertions about the rewritten query tree operations.each do |op_name, op_node| # Yield each node to listeners which were attached by validators op_node.typed_children.each do |obj_type, children| children.each do |name, op_child_node| each_node(op_child_node) do |node| for h in handlers h.call(node) end end end end end end |