-
Notifications
You must be signed in to change notification settings - Fork 90
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
Add getIfCached(key) in DataLoader #50
Comments
Are you think of a sifnature like
Where is returns the cached CF otherwise Remember the CF might not be resolved but its in the cache of CFs. Also remember the cache is a cache of promises ot Values not the Values themselves. You cant be sure the CF to Value has finished hence you cant really inspect it (I guess you can via Is that what you are after? |
if you could propose a change via a PR that would be great |
I started a proof of concept here Is this what you are after? |
Yes, that looks exactly like what I'm after. I was going to try to do something similar with a locally modified copy, but I guess you beat me to it :) |
I have released 2.2.3 with |
Thank you! That was super fast :) |
It'd be great if the DataLoader had a getIfCached method returning the future (or the actual object) if it exists, without triggering a load. Alternatively if the DataLoader had it's member variables as protected so that the class could be extended.
We have a quite complicated setup with lots of relationships between entities as well as partial loading of some entities. Occasionally we want to check if an item is in the DL cache and use it if it is (and has the data we need), otherwise go down a different path.
We also prime the cache of one data loader when loading a list of the same entities in a batch loader belonging to another data loader.
We try to avoid chaining dataloader calls in a thenCompose due to manual invocation of dispatch() causing double loads of the same entity from the same data-loader, so we instead want to implement some slightly more intelligent batch loaders.
The text was updated successfully, but these errors were encountered: