Bad Access Memories

TIL: DataLoaders

November 07, 2022

Saw it initially in gqlgen#Dataloaders but I believe the idea comes from engineering.fb.com.

This dataloader sits between the application layer, e.g. a GraphQL resolver, and the datasource, providing an abstraction to the latter where a single request can represent a batch of multiples.

Why does it matter?

Having a dataloader:

  • avoids redundant fetching of data, as subsequent requests with the same parameters will use the cached result.
  • avoids leaking datasource-specific logic, as it abstracts away their interface. One may be dealing with a database, a third-party service, or any other.

That's it for now 👋🏻