I’m using Observable Framework to build some dashboards that consumes some json api from an external site.
I have a data loader ./src/products/[category]/data.json.ts that essentially pulls the data from the api. A couple of MB.
I don’t need all that data in the client, so I would rather have a data loader ./src/products/[category]/stats.json.ts that would consume the ./data.json of that category.
This would allow other data loaders to exist that could also depend on the ./data.json. So effectively building a processing pipeline using data loaders, leveraging the cache to download MBs of api data only once on build time, and sending just the needed bits to the client by having specific data loaders.
I have not tried it but maybe the child can call the parent dataloader’s endpoint with a http call, so it ends up invoking the parent data loader? i.e. do the chaining in the network layer
What I’ve ended up doing to avoid repeated API calls is to have a single data loader (in Python) that outputs various files along the way. Then set up GitHub Actions to automatically commit and push the files. (It worked fine on my own computer without that step, but the files weren’t saving when it ran on GitHub.) I have no idea if it’s kosher, but it works. I describe the process in step #4 here, and you can see the data loader itself here.