Module: GraphQL::FragmentCache::Schema::Instrumentation

Defined in:
lib/graphql/fragment_cache/schema/instrumentation.rb

Overview

Adds hook for saving cached values after query is resolved

Defined Under Namespace

Modules: Tracer

Class Method Summary collapse

Class Method Details

.after_query(query) ⇒ Object



15
16
17
18
19
# File 'lib/graphql/fragment_cache/schema/instrumentation.rb', line 15

def after_query(query)
  return if skip_caching?(query)

  Cacher.call(query)
end

.before_query(query) ⇒ Object



12
13
# File 'lib/graphql/fragment_cache/schema/instrumentation.rb', line 12

def before_query(query)
end

.skip_caching?(query) ⇒ Boolean

Returns:

  • (Boolean)


21
22
23
24
# File 'lib/graphql/fragment_cache/schema/instrumentation.rb', line 21

def skip_caching?(query)
  !query.valid? ||
    GraphQL::FragmentCache.skip_cache_when_query_has_errors? && query.context.errors.any?
end