Get dataloader advantage on oneToMany relations with where statement
mschipperheyn opened this issue · 3 comments
I'm trying to figure out how to get the benefits of the dataloader loading all related items in one go in a couple of scenarios where the solutions is not obvious to me.
E.g.
Post
likes (Like: oneToMany)
I'm loading a list of posts and I want to verify if the current user liked any of them.
The ideal query is basically
select * from Likes where userId = <id> and postId in ([<postId>]);
I'm not if it's possible to benefit from dataloader and how to reach scenarios like this?
Currently it's not supported (IIRC), as we base the cache key on the where object: https://github.com/mickhansen/dataloader-sequelize/blob/master/src/index.js#L263
In theory it would be possible of course but would require some logic and work.
Ok, thanks.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.