Class: GraphQL::ResultCache::Callback

Inherits:
Object
  • Object
show all
Defined in:
lib/graphql/result_cache/callback.rb

Instance Method Summary collapse

Constructor Details

#initialize(obj:, args:, ctx:, value:) ⇒ Callback

Returns a new instance of Callback.



4
5
6
7
8
9
# File 'lib/graphql/result_cache/callback.rb', line 4

def initialize obj:, args:, ctx:, value:
  @obj = obj
  @args = args
  @ctx = ctx
  @value = value
end

Instance Method Details

#call(result_hash) ⇒ Object



11
12
13
14
15
16
17
18
19
# File 'lib/graphql/result_cache/callback.rb', line 11

def call result_hash
  case @value
    when Symbol
      @obj.public_send(@value, result_hash)
    when Proc
      @value.call(result_hash, @obj, @args, @ctx)
  end
  ::GraphQL::ResultCache.logger&.debug "GraphQL result cache callback called for #{@ctx.path.join('.')}"
end