Class: GraphQL::Cache::Fetcher
- Inherits:
-
Object
- Object
- GraphQL::Cache::Fetcher
- Defined in:
- lib/graphql/cache/fetcher.rb
Overview
Represents the "instrumenter" passed to GraphQL::Schema#instrument
when the plugin in initialized (i.e. use GraphQL::Cache
)
Instance Method Summary collapse
-
#instrument(type, field) ⇒ GraphQL::Schema::Field
Redefines the given field's resolve proc to use our custom cache wrapping resolver proc.
Instance Method Details
#instrument(type, field) ⇒ GraphQL::Schema::Field
Redefines the given field's resolve proc to use our custom cache wrapping resolver proc. Called from graphql-ruby internals. This is the "instrumenter" entrypoint.
14 15 16 17 18 19 20 21 |
# File 'lib/graphql/cache/fetcher.rb', line 14 def instrument(type, field) return field unless field.[:cache] cached_resolve_proc = cached_resolve(type, field) # Return a copy of `field`, with the new resolve proc field.redefine { resolve(cached_resolve_proc) } end |