Sha256: dc70faae92eacbabf53505a04e3cad05dee5c476ccb2a298d5ddffbb2fca8b20

Contents?: true

Size: 1.08 KB

Versions: 19

Compression:

Stored size: 1.08 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)
        # 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)
        yield(node)
        node.typed_children.each do |obj_type, children|
          children.each do |name, node|
            each_node(node) { |n| yield(n) }
          end
        end
      end
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
graphql-1.8.5 lib/graphql/internal_representation/visit.rb
graphql-1.8.4 lib/graphql/internal_representation/visit.rb
graphql-1.8.3 lib/graphql/internal_representation/visit.rb
graphql-1.8.2 lib/graphql/internal_representation/visit.rb
graphql-1.8.1 lib/graphql/internal_representation/visit.rb
graphql-1.8.0 lib/graphql/internal_representation/visit.rb
graphql-1.8.0.pre11 lib/graphql/internal_representation/visit.rb
graphql-1.8.0.pre10 lib/graphql/internal_representation/visit.rb
graphql-1.7.14 lib/graphql/internal_representation/visit.rb
graphql-1.8.0.pre9 lib/graphql/internal_representation/visit.rb
graphql-1.8.0.pre8 lib/graphql/internal_representation/visit.rb
graphql-1.7.13 lib/graphql/internal_representation/visit.rb
graphql-1.8.0.pre7 lib/graphql/internal_representation/visit.rb
graphql-1.7.12 lib/graphql/internal_representation/visit.rb
graphql-1.7.11 lib/graphql/internal_representation/visit.rb
graphql-1.7.10 lib/graphql/internal_representation/visit.rb
graphql-1.8.0.pre6 lib/graphql/internal_representation/visit.rb
graphql-1.8.0.pre5 lib/graphql/internal_representation/visit.rb
graphql-1.7.9 lib/graphql/internal_representation/visit.rb