Sha256: 490966fbe26043e2a843e528184090cf435ca54ce166d3832a28a534cc9e37c2

Contents?: true

Size: 1.12 KB

Versions: 68

Compression:

Stored size: 1.12 KB

Contents

# frozen_string_literal: true
module GraphQL
  module InternalRepresentation
    # Traverse a re-written query tree, calling handlers for each node
    module Visit
      module_function
      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

      # Traverse a node in a rewritten query tree,
      # visiting the node itself and each of its typed children.
      def each_node(node, &block)
        yield(node)
        node.typed_children.each do |obj_type, children|
          children.each do |name, node|
            each_node(node, &block)
          end
        end
      end
    end
  end
end

Version data entries

68 entries across 68 versions & 2 rubygems

Version Path
graphql-1.13.23 lib/graphql/internal_representation/visit.rb
graphql-1.13.22 lib/graphql/internal_representation/visit.rb
graphql-1.13.21 lib/graphql/internal_representation/visit.rb
graphql-1.13.20 lib/graphql/internal_representation/visit.rb
graphql-1.13.19 lib/graphql/internal_representation/visit.rb
graphql-1.13.18 lib/graphql/internal_representation/visit.rb
graphql-1.13.17 lib/graphql/internal_representation/visit.rb
graphql-1.13.16 lib/graphql/internal_representation/visit.rb
graphql-1.13.15 lib/graphql/internal_representation/visit.rb
graphql-1.13.14 lib/graphql/internal_representation/visit.rb
graphql-1.13.13 lib/graphql/internal_representation/visit.rb
graphql_cody-1.13.0 lib/graphql/internal_representation/visit.rb
graphql-1.13.12 lib/graphql/internal_representation/visit.rb
graphql-1.13.11 lib/graphql/internal_representation/visit.rb
graphql-1.13.10 lib/graphql/internal_representation/visit.rb
graphql-1.13.9 lib/graphql/internal_representation/visit.rb
graphql-1.12.24 lib/graphql/internal_representation/visit.rb
graphql-1.13.8 lib/graphql/internal_representation/visit.rb
graphql-1.13.7 lib/graphql/internal_representation/visit.rb
graphql-1.13.6 lib/graphql/internal_representation/visit.rb