{"repo":"vikstrous/dataloadgen","free":true,"listed":false,"github":"https://github.com/vikstrous/dataloadgen","clone":"git clone https://github.com/vikstrous/dataloadgen.git","description":"An implementation of Facebook's DataLoader in Go","language":"Go","stars":126,"topics":["dataloader","gqlgen","graphql"],"license":"MIT","category":"api-integrations-sdks","readme_excerpt":"dataloadgen dataloadgen is an implementation of a pattern popularized by Facebook's DataLoader. It works as follows: A Loader object is created per graphql request. Each of many concurrently executing graphql resolver functions call Load() on the Loader object with different keys. Let's say K1 , K2 , K3 Each call to Load() with a new key is delayed slightly (a few milliseconds) so that the Loader can load them together. The customizable fetch function of the loader takes a list of keys and loads data for all of them in a single batched request to the data storage layer. It might send [K1,K2,K3] and get back [V1,V2,V3] . The order of the keys must match the order of the values. Alternatively, the mappedFetch function of the loader takes a list of keys and returns a map instead of a list. It might send [K1, K2, K3] and get back {K1: V1, K2: V2, K3: V3} . The Loader takes care of sending the right result to the right caller and the result is cached for the duration of the graphql request. [!NOTE] The fetch method expects the returned list to correspond to the provided keys in the same order. Alternatively, the mappedFetch allows returning a map, ensuring correct ordering and automatic creation of the ErrNotFound error for missing values. Usage: See the usage example in the documentation: Comparison to others dataloaden uses code generation and has similar performance dataloader does not use code generation but has much worse performance and is more difficult to use yckao/go-data","default_branch":null,"files":null,"tree":[],"storefront":"/r/vikstrous","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/vikstrous/dataloadgen/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."}