-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
executeSubSelectedArray
cache is full of empty arrays
#11669
Comments
The point of the "cache" of You shouldn't be concerned that this cache holds 22k elements, and most of them empty arrays. It's still valuable information, as in these 15k "extra" cases, all of them come "from different inputs". |
That said, we could get around this for the specific case of empty arrays, but it has some tradeoffs. |
Do you have any feedback for the maintainers? Please tell us by taking a one-minute survey. Your responses will help us understand Apollo Client usage and allow us to serve you better. |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Issue Description
Hello all,
On an application with loads of data, and especially lists, I noticed a behavior that
executeSubSelectedArray
cache fills up disproportionately fast to the amount of data in the application. It's a scheduling application, and we have a lot of deeply nested data - that keeps default normalization - with a lot of fields that are lists. Something like:Usually, all those lists (holidays, events, etc.) are empty, it's rare that they have some data in them. To indicate that they're empty, we return empty array from back-end/data source, which seems to be a common pattern and helps avoiding optional chaining everywhere. However, apollo client seems to treat all those empty arrays as any other array, which on one hand is correct, but it seems like treating an empty array as nothing, or frankly null, and not storing it in cache would be beneficial. In our case, returning
null
instead of an empty array for those lists reduced the number of entries inexecuteSubSelectedArray
from around 6k to 2.2k. That may look like a specific case, but I believe we are following a common pattern here, and it's unexpected that >60% ofexecuteSubSelectedArray
is filled with nothing but air, or in other words empty arrays.I've added a reproduction example where I modified the default template to include an always empty list with every person. It now creates a new entry for every person in
executeSubSelectedArray
, even though I'd argue treating empty array as nothing would be preferable, and it should not be cached.Link to Reproduction
https://codesandbox.io/p/devbox/quizzical-darwin-rygm6d?workspaceId=09e55846-a4b6-4a71-876a-5fe11037e12f
Reproduction Steps
No response
@apollo/client
version3.9
The text was updated successfully, but these errors were encountered: