Sha256: 0acbf3c59d3188bc3f59ac9a0e0ebb1ca8e3cfaf7b5bd9df9b37427909e017d4

Contents?: true

Size: 861 Bytes

Versions: 155

Compression:

Stored size: 861 Bytes

Contents

# frozen_string_literal: true
module GraphQL
  module Execution
    # Starting from a root context,
    # create a hash out of the context tree.
    # @api private
    module Flatten
      def self.call(ctx)
        flatten(ctx)
      end

      class << self
        private

        def flatten(obj)
          case obj
          when Hash
            flattened = {}
            obj.each do |key, val|
              flattened[key] = flatten(val)
            end
            flattened
          when Array
            obj.map { |v| flatten(v) }
          when Query::Context::SharedMethods
            if obj.invalid_null?
              nil
            elsif obj.skipped? && obj.value.empty?
              nil
            else
              flatten(obj.value)
            end
          else
            obj
          end
        end
      end
    end
  end
end

Version data entries

155 entries across 155 versions & 2 rubygems

Version Path
graphql-1.11.12 lib/graphql/execution/flatten.rb
graphql-1.11.11 lib/graphql/execution/flatten.rb
graphql-1.12.25 lib/graphql/execution/flatten.rb
graphql-1.13.24 lib/graphql/execution/flatten.rb
graphql-1.13.23 lib/graphql/execution/flatten.rb
graphql-1.13.22 lib/graphql/execution/flatten.rb
graphql-1.13.21 lib/graphql/execution/flatten.rb
graphql-1.13.20 lib/graphql/execution/flatten.rb
graphql-1.13.19 lib/graphql/execution/flatten.rb
graphql-1.13.18 lib/graphql/execution/flatten.rb
graphql-1.13.17 lib/graphql/execution/flatten.rb
graphql-1.13.16 lib/graphql/execution/flatten.rb
graphql-1.13.15 lib/graphql/execution/flatten.rb
graphql-1.13.14 lib/graphql/execution/flatten.rb
graphql-1.13.13 lib/graphql/execution/flatten.rb
graphql_cody-1.13.0 lib/graphql/execution/flatten.rb
graphql-1.13.12 lib/graphql/execution/flatten.rb
graphql-1.13.11 lib/graphql/execution/flatten.rb
graphql-1.13.10 lib/graphql/execution/flatten.rb
graphql-1.13.9 lib/graphql/execution/flatten.rb