+1. The JS event loop auto-monad-izing Promises into Haxl [1]-esqe trees of implicitly-batched loads has been a big win for us building on JavaScript/TypeScript.
If I had to move to another language, I'd really want to find a "powered by the event loop / dataloader" framework, i.e. Vert.x for Java.
Also, per dataloader, a shameless plug for our ORM that has dataloader de-N+1-ing built natively into all object graph traversals:
> The JS event loop auto-monad-izing Promises into Haxl [1]-esqe trees of implicitly-batched loads
can you explain what this means?
Re:Ban 1+N in Django
by eurasiantiger on Monday March 27, 2023 @01:03AM
(#35323021)
So, in other words, you want GraphQL.
A dataloader sort of pattern tends to be on the implementing end of GraphQL.
Re:Ban 1+N in Django
by eurasiantiger on Monday March 27, 2023 @07:11AM
(#35325196)
Indeed, the parent was describing built-in features of the Apollo GraphQL Client, such as entity-level caching in the frontend.
However, a dataloader pattern can also be useful when implementing custom resolvers for a GraphQL API. For this purpose, Apollo provides data sources which handle caching at request level.
If you have multiple ways to 'see' the same X from multiple Y objects, then all of this get complicated quickly.
Once you're there a microservice has some advantages. Wrap a cache with a service, implement multi-get, anything not in the cache calls through to the database.
Unfortunately this pattern gets really hairy if you're not using promises and an event loop.
https://www.npmjs.com/package/dataloader