Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(core): do not update completed mutations #7104

Merged
merged 4 commits into from Mar 14, 2024
Merged

Conversation

gautemo
Copy link
Contributor

@gautemo gautemo commented Mar 13, 2024

fixes #6839

This PR fixes that updating options on a mutation will update the latest mutation in the cache, even though it is completed.

Copy link

vercel bot commented Mar 13, 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 Mar 14, 2024 3:25pm

Copy link

codesandbox-ci bot commented Mar 13, 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 b230873:

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

@@ -169,4 +169,128 @@ describe('mutationObserver', () => {

unsubscribe()
})

test('changing mutation meta should not affect successful mutations', async () => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it would be good to also test the following scenario:

  • set meta to { a: 1 }
  • call mutate, wait until it's done
  • trigger a re-render, update meta to { a: 2 }
  • call mutate again, wait until it's done

after that, we should have two mutations in the cache, where the first one has { a: 1 } and the second one has { a: 2 }

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, added a test mutation cache should have different meta when updated between mutations in the latest commit. Also changed meta property names from count to a.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a was just an example, you didn't need to rename it 😂

Copy link

nx-cloud bot commented Mar 14, 2024

☁️ Nx Cloud Report

CI is running/has finished running commands for commit b230873. 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 2 targets

Sent with 💌 from NxCloud.

@TkDodo
Copy link
Collaborator

TkDodo commented Mar 14, 2024

please fix formatting

@gautemo
Copy link
Contributor Author

gautemo commented Mar 14, 2024

please fix formatting

Sorry about that, should be fixed now

@TkDodo TkDodo merged commit 75131d6 into TanStack:main Mar 14, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Mutation cache, old mutations gets updated key and meta on state updates
2 participants