lib/graphql/schema/field.rb
# Wrap execution with hooks.
# Written iteratively to avoid big stack traces.
# @return [Object] Whatever the
Wrap execution with hooks.
Written iteratively to avoid big stack traces.
Wrap execution with hooks . Written iteratively to avoid big stack traces .
def with_extensions(obj, args, ctx)
        if @extensions.empty?
          yield(obj, args)
        else
          extended = { args: args, obj: obj, memos: nil }
          value = run_extensions_before_resolve(obj, args, ctx, extended) do |obj, args|
            yield(obj, args)
          end
          extended_obj = extended[:obj]
          extended_args = extended[:args]
          memos = extended[:memos] || EMPTY_HASH
          ctx.schema.after_lazy(value) do |resolved_value|
            idx = 0
            @extensions.each do |ext|
              memo = memos[idx]
              resolved_value = ext.after_resolve(object: extended_obj, arguments: extended_args, context: ctx, value: resolved_value, memo: memo)
              idx += 1
            end
            resolved_value
          end
        end
      end
def with_extensions ( obj , args , ctx ) if @extensions . empty? yield ( obj , args ) else extended = { args : args , obj : obj , memos : nil } value = run_extensions_before_resolve ( obj , args , ctx , extended ) do | obj , args | yield ( obj , args ) end extended_obj = extended [ :obj ] extended_args = extended [ :args ] memos = extended [ :memos ] || EMPTY_HASH ctx . schema . after_lazy ( value ) do | resolved_value | idx = 0 @extensions . each do | ext | memo = memos [ idx ] resolved_value = ext . after_resolve ( object : extended_obj , arguments : extended_args , context : ctx , value : resolved_value , memo : memo ) idx += 1 end resolved_value end end end
Wrap execution with hooks.
Wrap execution with hooks .
# This is a hack to get the _last_ value for extended obj and args, # in case one of the extensions doesn't `yield`. # (There's another implementation that uses multiple-return, but I'm wary of the perf cost of the extra arrays) # TODO after_lazy?
None
Object
obj
args
ctx