Skip to content

Commit e71d9ba

Browse files
committed
fix upserting
1 parent d9e481b commit e71d9ba

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

packages/toolkit/src/query/core/buildSlice.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,8 @@ export function buildSlice({
136136
extraReducers(builder) {
137137
builder
138138
.addCase(queryThunk.pending, (draft, { meta, meta: { arg } }) => {
139-
if (arg.subscribe) {
139+
const upserting = isUpsertQuery(arg)
140+
if (arg.subscribe || upserting) {
140141
// only initialize substate if we want to subscribe to it
141142
draft[arg.queryCacheKey] ??= {
142143
status: QueryStatus.uninitialized,
@@ -148,7 +149,7 @@ export function buildSlice({
148149
substate.status = QueryStatus.pending
149150

150151
substate.requestId =
151-
isUpsertQuery(arg) && substate.requestId
152+
upserting && substate.requestId
152153
? // for `upsertQuery` **updates**, keep the current `requestId`
153154
substate.requestId
154155
: // for normal queries or `upsertQuery` **inserts** always update the `requestId`

0 commit comments

Comments
 (0)