A query batching executor for the graphql gem. Provides an executor for the graphql gem which allows queries to be batched. Define a custom loader, which is initialized with arguments that are used for grouping and a perform method for performing the batch load. 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. 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. Although this library doesn't have a dependency on active record, the examples directory has record and association loaders for active record which handles edge cases like type-casting ids. GraphQL::Batch::Loader#load returns a Promise using the promise.rb gem to provide a promise-based API, so you can transform the query results using .then.
Features
- Schema Configuration
- The loader also supports batch loading an array of records
- Unit Testing
- Provides an executor for the graphql gem
- Allows queries to be batched
- Your loaders can be tested outside of a GraphQL query