module GraphQL::Execution::Flatten
Starting from a root context, create a hash out of the context tree. @api private
Public Class Methods
call(ctx)
click to toggle source
# File lib/graphql/execution/flatten.rb, line 7 def self.call(ctx) flatten(ctx) end
Private Class Methods
flatten(obj)
click to toggle source
# File lib/graphql/execution/flatten.rb, line 14 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