README.md in graphql-batch-0.4.3 vs README.md in graphql-batch-0.5.0
- old
+ new
@@ -48,31 +48,21 @@
end
```
Use `GraphQL::Batch` as a plugin in your schema _after_ specifying the mutation
so that `GraphQL::Batch` can extend the mutation fields to clear the cache after
-they are resolved (for graphql >= `1.5.0`).
+they are resolved.
```ruby
class MySchema < GraphQL::Schema
query MyQueryType
mutation MyMutationType
use GraphQL::Batch
end
```
-For pre `1.5.0` versions:
-
-```ruby
-MySchema = GraphQL::Schema.define do
- query MyQueryType
-
- GraphQL::Batch.use(self)
-end
-```
-
#### Field Usage
The loader class can be used from the resolver for a graphql field by calling `.for` with the grouping arguments to get a loader instance, then call `.load` on that instance with the key to load.
```ruby
@@ -153,22 +143,22 @@
```
## 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
+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
promise returned from the block then clear the thread-local state
to avoid leaking state between tests.
```ruby
- def test_single_query
- product = products(:snowboard)
- title = GraphQL::Batch.batch do
- RecordLoader.for(Product).load(product.id).then(&:title)
- end
- assert_equal product.title, title
+def test_single_query
+ product = products(:snowboard)
+ title = GraphQL::Batch.batch do
+ RecordLoader.for(Product).load(product.id).then(&:title)
end
+ assert_equal product.title, title
+end
```
## Development
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.