Discovering Dataloader
The challenge here is getting the data we want efficiently without coupling our GraphQL API tightly to the SQL structure of our data, and without stuffing our contexts full of tons of functions that exist just for GraphQL purposes. We want to respect the idea that our contexts define a boundary, and if we start just doing Ecto queries in all of our resolvers, we’ll be violating that boundary. At the same time, GraphQL’s flexibility means that without a little bit of help, we’re going to end up with dozens of functions within our context to handle every scenario.
Dataloader is a small package that defines a minimalist API for getting data in batches. We can use it within our contexts to keep all the SQL details nicely packed ...
Get Craft GraphQL APIs in Elixir with Absinthe now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.