{"repo":"Shopify/graphql-batch","free":true,"listed":false,"github":"https://github.com/Shopify/graphql-batch","clone":"git clone https://github.com/Shopify/graphql-batch.git","description":"A query batching executor for the graphql gem","language":"Ruby","stars":1441,"topics":["graphql","promise","batch"],"license":"MIT","category":"api-integrations-sdks","readme_excerpt":"GraphQL::Batch Provides an executor for the graphql gem which allows queries to be batched. Installation Add this line to your application's Gemfile: And then execute: $ bundle Or install it yourself as: $ gem install graphql-batch Usage Basic Usage Schema Configuration Require the library 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. 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. The loader also supports batch loading an array of records instead of just a single record, via load many . For example: 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 and overriding GraphQL::Batch::Loader#cache key to load associations on records with the same id. Promises 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 You may also need to do another query that depends on the first one to get the result, in which case the query block can ","default_branch":null,"files":null,"tree":[],"storefront":"/r/Shopify","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/Shopify/graphql-batch/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}