README.md in graphql-batch-0.5.4 vs README.md in graphql-batch-0.6.0
- old
+ new
@@ -138,9 +138,25 @@
RecordLoader.for(Product).load(id)
end)
end
```
+### Priming the Cache
+
+You can prime the loader cache with a specific value, which can be useful in certain situations.
+
+```ruby
+def liked_products
+ liked_products = Product.where(liked: true).load
+ liked_products.each do |product|
+ RecordLoader.for(Product).prime(product.id, product)
+ end
+end
+```
+
+Priming will add key/value to the loader cache only if it didn't exist before.
+
+
## Unit Testing
Your loaders can be tested outside of a GraphQL query by doing the
batch loads in a block passed to `GraphQL::Batch.batch`. That method
will set up thread-local state to store the loaders, batch load any