Sha256: 62a39809d4b8267a8793eb12fc30eecb0dfd30259df4e10a0c803e6ccd1c9841

Contents?: true

Size: 1.17 KB

Versions: 36

Compression:

Stored size: 1.17 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)
        if node.typed_children.any?
          visit_block = Proc.new
          node.typed_children.each do |obj_type, children|
            children.each do |name, node|
              each_node(node, &visit_block)
            end
          end
        end
      end
    end
  end
end

Version data entries

36 entries across 36 versions & 1 rubygems

Version Path
graphql-1.8.0.pre4 lib/graphql/internal_representation/visit.rb
graphql-1.8.0.pre3 lib/graphql/internal_representation/visit.rb
graphql-1.7.8 lib/graphql/internal_representation/visit.rb
graphql-1.8.0.pre2 lib/graphql/internal_representation/visit.rb
graphql-1.7.7 lib/graphql/internal_representation/visit.rb
graphql-1.8.0.pre1 lib/graphql/internal_representation/visit.rb
graphql-1.7.6 lib/graphql/internal_representation/visit.rb
graphql-1.7.5 lib/graphql/internal_representation/visit.rb
graphql-1.7.4 lib/graphql/internal_representation/visit.rb
graphql-1.7.3 lib/graphql/internal_representation/visit.rb
graphql-1.7.2 lib/graphql/internal_representation/visit.rb
graphql-1.7.1 lib/graphql/internal_representation/visit.rb
graphql-1.7.0 lib/graphql/internal_representation/visit.rb
graphql-1.6.8 lib/graphql/internal_representation/visit.rb
graphql-1.6.7 lib/graphql/internal_representation/visit.rb
graphql-1.6.6 lib/graphql/internal_representation/visit.rb
graphql-1.6.5 lib/graphql/internal_representation/visit.rb
graphql-1.6.4 lib/graphql/internal_representation/visit.rb
graphql-1.5.15 lib/graphql/internal_representation/visit.rb
graphql-1.6.3 lib/graphql/internal_representation/visit.rb