-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* refactor: add scope to mutationCache internally * refactor: remove unused defaultOptions on mutation this private field is a leftover from v4 * feat: make sure to not run mutations if there is already one running in the scope of this mutation * feat: make sure mutations in the same scope can run in serial * fix: find a _lot_ better way to determine if a mutation can run * test: widen test scenario to include scopes * fix: there is a difference between starting and continuing when starting, we need to check the networkMode differently than when continuing, because of how offlineFirst works (can start, but can't continue) * refactor: switch to a scope object with `id` * feat: dehydrate and hydrate mutation scope * fix: initiate the mutationCache with a random number since we use the mutationId to create the default scope, and the mutationId is merely incremented, we risk colliding scopes when hydrating mutations into an existing cache. That's because the mutationId itself is never dehydrated. When a mutation gets hydrated, it gets re-built, thus getting a new id. At this point, its id and the scope can differ. That per se isn't a problem. But if a mutation was dehydrated with scope:1, it would put into the same scope with another mutation from the new cache that might also have the scope:1. To avoid that, we can initialize the mutationId with Date.now(). It will make sure (or at least very likely) that there is no collision In the future, we should just be able to use `Crypto.randomUUID()` to generate a unique scope, but our promised compatibility doesn't allow for using this function * test: hydration * test: those tests actually fail because resumePausedMutations is still wrongly implemented * fix: simplify and fix resumePausedMutations we can fire off all mutations at the same time - only the first one in each scope will actually fire, the others have to stay paused until their time has come. mutation.continue handles this internally. but, we get back all the retryer promises, so resumePausedMutations will wait until the whole chain is done * test: more tests * refactor: scopeFor doesn't use anything of the mutationCache class * docs: scoped mutations
- Loading branch information
Showing
12 changed files
with
473 additions
and
97 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
Oops, something went wrong.