Repository navigation
💥 Replace the concat mutation hook with mutation scopes - #219
Merged
Merged
Conversation
…other TanStack Query queues mutations that share a `scope.id`. The test pins that `useMutation$` settles each one in time for the next to start: on an error, and on the stream's first value while the stream stays open. Claude-Session: https://claude.ai/code/session_01BvSDyJABLGit75HAjpnsqm
…arallel
`useConcatMutation$` called `mutationFn` as soon as `mutate` ran and
only delayed the subscription. A `mutationFn` that starts its work in
the call, such as `(v) => from(save(v))`, sent every request at once.
TanStack Query queues mutations that share a `scope.id`, and
`useMutation$` passes `scope` through. The useMutation$ docs page now
covers it.
BREAKING CHANGE: `useConcatMutation$` is removed. Queue mutations with a
scope instead: `useConcatMutation$({ mutationKey: ["save"], ... })`
becomes `useMutation$({ scope: { id: "save" }, ... })`, whose `data` is
typed `TData` rather than `TData | null`.
Claude-Session: https://claude.ai/code/session_01BvSDyJABLGit75HAjpnsqm
mbret
marked this pull request as ready for review
November 3, 2026 10:56
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Writes queued with
useConcatMutation$can overtake each other, so an older value can overwrite a newer one.The hook delays only the subscription. A
mutationFnthat starts its request when called still sends every request at once.scopeoption, whichuseMutation$already passes through.What's new
useConcatMutation$is removed: queue mutations withuseMutation$andscope: { id }Other changes
useMutation$calls sharing a scope start in turn, after a failure or a first valueuseMutation$docs pageDetails
Migration
The result no longer includes
null:dataisTData | undefined, andmutateAsyncresolvesTData.What the hook did
It built each source with
mutationFn(variables)whenmutateran, then waited for earlier mutations before subscribing. ThreemutateAsynccalls withmutationFn: (v) => from(request(v))had three requests in flight at once. Deferring the call would fix that, but TanStack Query already keeps the same queue.How
scopebehavesscopeexists in every@tanstack/react-queryversion the peer range allows.onMutateruns whenmutateis called, then the mutation waits its turn, as it did with the hook.🔍 Self-reviewed with selfcorrect-review
🤖 Made within harness coverage
Generated by Claude Code