-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rename cache.batch options.transaction function to options.update.
I've never felt like "transaction" was exactly the right word for what cache.performTransaction and cache.batch are doing. For example, the updates are not automatically undone on failure like the word "transaction" suggests, unless you're recording against an optimistic layer that you plan to remove later, via cache.recordOptimisticTransaction and cache.removeOptimistic. In reality, the primary purpose of cache.performTransaction and cache.batch is to batch up broadcastWatches notifications for cache updates that take place within the callback function. I chose options.update because I think it's generic enough to avoid giving any mistaken interpretations of the purpose or usage of the function, unlike options.transaction. Separately, I believe options.update better aligns with the naming of the options.updateCache function for client.refetchQueries. Which may lead you to ask... Why not call it updateCache, exactly like client.refetchQueries? This is certainly a matter of subjective taste, but to me it feels redundant (and not useful for readability) to have to type the extra -Cache suffix every time you call cache.batch (which is more clearly a cache-updating method than client.refetchQueries is): cache.batch({ updateCache(cache) {...}, ... }) This commit will allow the following code, which eliminates the redundancy without sacrificing readability: cache.batch({ update(cache) {...}, ... }) For comparison, client.refetchQueries needs the extra specificity of updateCache because it gives readers of the code a clue about what's being updated (namely, the cache): client.refetchQueries({ updateCache(cache) {...}, ... })
- Loading branch information
Showing
5 changed files
with
33 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters