Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to bypass batching/caching ? #75

Closed
ArnaudD opened this issue Apr 29, 2019 · 5 comments
Closed

How to bypass batching/caching ? #75

ArnaudD opened this issue Apr 29, 2019 · 5 comments
Labels

Comments

@ArnaudD
Copy link

ArnaudD commented Apr 29, 2019

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 !

@mickhansen
Copy link
Owner

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.

@ArnaudD
Copy link
Author

ArnaudD commented Apr 29, 2019

Thanks for your quick response :)

Something like this ? https://github.com/mickhansen/dataloader-sequelize/compare/master...fizix-io:remove-global-cache?expand=1

@mickhansen
Copy link
Owner

Yeah that looks reasonable, if you open a PR i can get that deployed.

@ArnaudD
Copy link
Author

ArnaudD commented Apr 30, 2019

Great. I will update tests before opening a PR. Thanks!

@stale
Copy link

stale bot commented Apr 23, 2020

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.

@stale stale bot added the wontfix label Apr 23, 2020
@stale stale bot closed this as completed Apr 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants