Class: GraphQL::Sources::RailsCache
- Inherits:
-
Dataloader::Source
- Object
- Dataloader::Source
- GraphQL::Sources::RailsCache
- Defined in:
- lib/graphql/sources/rails_cache.rb
Overview
Instance Method Summary collapse
Instance Method Details
#fetch(operations) ⇒ Object
18 19 20 21 22 23 |
# File 'lib/graphql/sources/rails_cache.rb', line 18 def fetch(operations) keys = operations.pluck(:key) fallbacks = operations.to_h { |operation| [operation[:key], operation[:fallback]] } results = Rails.cache.fetch_multi(*keys) { |key| fallbacks[key].call } keys.map { |key| results[key] } end |