Sindre
Sindre4mo ago

Good patterns for large list querys? Invalidation & refetching gets slow after a mutation

We have several large lists where we invalidate the query after editing an item. What are some good patterns for this? The network lag starts adding up for the customers with more data. Ironically those who use us the most 😄 Is it "good practice" to edit the list query cache directly in the mutation onSuccess? Or necessary to refactor the list querys to be smaller, through server filters or infiniteQuery? Especially painful in a view where we have two lists where the user can connect items from one list to the items in the other list. Requiring both list queries to be invalidated. Better to make the "connections" mapping its own api procedure and only invalidate that? Or combine all three to one query, set the cache state manualle in the mutation onSuccess?
Kind of a react-query question I know, just wondering if anyone here has faced it. And if it has been written about
1 Reply
Sindre
SindreOP4mo ago
After searching for more discussion in the react-query discord, it seems that setting the data is the only option. Other than really improving the fetch times: https://discord.com/channels/719702312431386674/1176452917855780894/1176452917855780894 We ended up optimizing the backend more first which helped a ton and for the specific place where you can match items in the two lists, we made a third list for the "matches" which is mostly contained in one db table and is superfast