Skip to content

Conversation

@TkDodo
Copy link
Collaborator

@TkDodo TkDodo commented Apr 21, 2024

No description provided.

TkDodo added 18 commits March 15, 2024 13:56
this private field is a leftover from v4
when starting, we need to check the networkMode differently than when continuing, because of how offlineFirst works (can start, but can't continue)
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
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
@vercel
Copy link

vercel bot commented Apr 21, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
query ⬜️ Ignored (Inspect) Visit Preview Apr 21, 2024 8:13am

@nx-cloud
Copy link

nx-cloud bot commented Apr 21, 2024

☁️ Nx Cloud Report

CI is running/has finished running commands for commit 1294869. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this CI Pipeline Execution


✅ Successfully ran 1 target

Sent with 💌 from NxCloud.

@codesandbox-ci
Copy link

codesandbox-ci bot commented Apr 21, 2024

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 1294869:

Sandbox Source
@tanstack/query-example-angular-basic Configuration
@tanstack/query-example-react-basic-typescript Configuration
@tanstack/query-example-solid-basic-typescript Configuration
@tanstack/query-example-svelte-basic Configuration
@tanstack/query-example-vue-basic Configuration

@github-actions github-actions bot added the documentation Improvements or additions to documentation label Apr 21, 2024
@TkDodo TkDodo marked this pull request as ready for review April 21, 2024 08:34
@TkDodo TkDodo merged commit 24f1d45 into main Apr 22, 2024
@TkDodo TkDodo deleted the feature/scoped-mutations branch April 22, 2024 06:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation package: query-core package: react-query

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants