Class: GraphQL::ResultCache::Schema::FieldExtension

Inherits:
Schema::FieldExtension
  • Object
show all
Defined in:
lib/graphql/result_cache/schema/field_extension.rb

Instance Method Summary collapse

Instance Method Details

#resolve(object:, arguments:, context:) {|object, arguments| ... } ⇒ Object

Yields:

  • (object, arguments)


12
13
14
15
16
17
18
19
20
21
# File 'lib/graphql/result_cache/schema/field_extension.rb', line 12

def resolve(object:, arguments:, context:)
  cache_config = options.respond_to?(:to_h) ? options.to_h : {}

  if Condition.new(cache_config, obj: object, args: arguments, ctx: context).true?
    context[:result_cache] ||= ContextConfig.new
    cached = add_to_context_result_cache(context, object, arguments, cache_config)
  end

  yield(object, arguments) unless cached
end