-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Closed
Description
As discussed in this discussion, the MutationCache is currently ever growing. This can be a problem because mutations are not shared like queries are, and are also never garbage collected. If mutations return big responses, those will be held in memory indefinitely.
Proposed solution
Add a cacheTime
to MutationCache
, and default to 5 minutes (same time as for queries). We can't remove mutations from the cache instantly after the last observer unmounts, because callacks on useMutation
might fire after that.
For that, we also need to notify the cache when an observer is added or removed for a mutation. The code for scheduling garbageCollection could be shared between queries and mutations via a base class that both Query
and Mutation
could extend.