Replies: 2 comments
-
Hey @lisherwin, how did you solve this in the end? If you don't mind sharing. I'm currently trying to solve the same thing |
Beta Was this translation helpful? Give feedback.
0 replies
-
Thanks for the post. For our situation we decided to go with option 2 since we only needed to select one at a time. I think for more complex situations https://github.com/yornaath/batshit might be worth considering. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi!
What is the best option for structuring query keys to cache batched data returned from endpoints? For example, we might have an endpoint like
/prices?tickers=AAPL,GOOG,AMZN,...
that will return a list of all prices for a provided set of stock tickers. We'd like to share this pricing data across all components that may require any subset of these stock prices.I have come across the following ideas, but they seem to have their own limitations.
["prices", "AAPL"], ["prices", "GOOG"], ["prices", "AMZN"]...
select
function into the query hook.["prices"]
where the value is something like{"AAPL": 144.29, "GOOG": 99.87, "AMZN": 103.13}
.["prices"]
, which would re-render all active queries on the prices query hook. I've also read that excessive use of select across many components can hinder performance.["prices", { tickers: ["AAPL", "GOOG", "AMZN"] }]
["prices", { tickers: ["AAPL"] }]
) will not load already cached data from RQ and we would introduce a query key for potentially every permutation of items we could fetch for (even more unbounded than approach 1).queryKey
most accurately matched the dependencies of ourqueryFn
. However, we realized that data was not being shared across components that fetched for a different subset of items, since it doesn't seem like there's a way for RQ to tell that there's overlap in the queryKey.notifyManager.batch
but was unclear if/how this would help with this problem and there seemed to be limited documentation on this.Any advice would help here, since we're not sure if we overlooked any obvious APIs or solutions. I'm more than happy to provide a code sandbox for these solutions, but I am thinking that this is fairly self-explanatory without code. Thank you in advance for all your help!
Beta Was this translation helpful? Give feedback.
All reactions