How to bypass batching/caching ?
ArnaudD opened this issue · 5 comments
Hi!
I would like to bypass dataloader-sequelize loaders as a workaround for #39
I tried omitting {[EXPECTED_OPTIONS_KEY]: context}
option but I found out that requests are batched anyway.
Here is the code (https://github.com/ArnaudD/test-dataloader/blob/master/index.js) :
User.findByPk(1, {[EXPECTED_OPTIONS_KEY]: context}),
User.findByPk(2, {[EXPECTED_OPTIONS_KEY]: context}),
User.findByPk(3), // dataloader should be batching this ?
User.findByPk(4), // dataloader should be batching this ?
I am expecting to see these requests in the logs :
SELECT `id`, ... FROM `users` AS `user` WHERE `user`.`id` IN (1, 2);
SELECT `id`, ... FROM `users` AS `user` WHERE `user`.`id` = 3;
SELECT `id`, ... FROM `users` AS `user` WHERE `user`.`id` = 4;
but instead I got this :
SELECT `id`, ... FROM `users` AS `user` WHERE `user`.`id` IN (1, 2);
SELECT `id`, ... FROM `users` AS `user` WHERE `user`.`id` IN (3, 4);
Is it a bug or a feature ?
Thanks for your help !
It's not really either, the example without EXPECTED_OPTIONS_KEY works because that was how it worked in legacy (without caching).
We should be able to remove the legacy code and publish a major to solve this issue though.
Thanks for your quick response :)
Something like this ? https://github.com/mickhansen/dataloader-sequelize/compare/master...fizix-io:remove-global-cache?expand=1
Yeah that looks reasonable, if you open a PR i can get that deployed.
Great. I will update tests before opening a PR. 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.