Skip to content

Commit 1a72462

Browse files
committed
chore: revert context deprecation on MutationState
1 parent 3109aef commit 1a72462

File tree

3 files changed

+15
-21
lines changed

3 files changed

+15
-21
lines changed

packages/query-core/src/mutation.ts

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,7 @@ export interface MutationState<
2929
TVariables = unknown,
3030
TOnMutateResult = unknown,
3131
> {
32-
/**
33-
* @deprecated `context` was renamed to `scope`. This will be removed in the next major version. Use the `scope` property instead.
34-
*/
3532
context: TOnMutateResult | undefined
36-
scope: TOnMutateResult | undefined
3733
data: TData | undefined
3834
error: TError | null
3935
failureCount: number
@@ -54,7 +50,7 @@ interface PendingAction<TVariables, TOnMutateResult> {
5450
type: 'pending'
5551
isPaused: boolean
5652
variables?: TVariables
57-
scope?: TOnMutateResult
53+
context?: TOnMutateResult
5854
}
5955

6056
interface SuccessAction<TData> {
@@ -221,14 +217,14 @@ export class Mutation<
221217
this as Mutation<unknown, unknown, unknown, unknown>,
222218
mutationFnContext,
223219
)
224-
const scope = await this.options.onMutate?.(
220+
const context = await this.options.onMutate?.(
225221
variables,
226222
mutationFnContext,
227223
)
228-
if (scope !== this.state.scope) {
224+
if (context !== this.state.context) {
229225
this.#dispatch({
230226
type: 'pending',
231-
scope,
227+
context,
232228
variables,
233229
isPaused,
234230
})
@@ -240,15 +236,15 @@ export class Mutation<
240236
await this.#mutationCache.config.onSuccess?.(
241237
data,
242238
variables,
243-
this.state.scope,
239+
this.state.context,
244240
this as Mutation<unknown, unknown, unknown, unknown>,
245241
mutationFnContext,
246242
)
247243

248244
await this.options.onSuccess?.(
249245
data,
250246
variables,
251-
this.state.scope,
247+
this.state.context,
252248
mutationFnContext,
253249
)
254250

@@ -257,7 +253,7 @@ export class Mutation<
257253
data,
258254
null,
259255
this.state.variables,
260-
this.state.scope,
256+
this.state.context,
261257
this as Mutation<unknown, unknown, unknown, unknown>,
262258
mutationFnContext,
263259
)
@@ -266,7 +262,7 @@ export class Mutation<
266262
data,
267263
null,
268264
variables,
269-
this.state.scope,
265+
this.state.context,
270266
mutationFnContext,
271267
)
272268

@@ -278,15 +274,15 @@ export class Mutation<
278274
await this.#mutationCache.config.onError?.(
279275
error as any,
280276
variables,
281-
this.state.scope,
277+
this.state.context,
282278
this as Mutation<unknown, unknown, unknown, unknown>,
283279
mutationFnContext,
284280
)
285281

286282
await this.options.onError?.(
287283
error as TError,
288284
variables,
289-
this.state.scope,
285+
this.state.context,
290286
mutationFnContext,
291287
)
292288

@@ -295,7 +291,7 @@ export class Mutation<
295291
undefined,
296292
error as any,
297293
this.state.variables,
298-
this.state.scope,
294+
this.state.context,
299295
this as Mutation<unknown, unknown, unknown, unknown>,
300296
mutationFnContext,
301297
)
@@ -304,7 +300,7 @@ export class Mutation<
304300
undefined,
305301
error as TError,
306302
variables,
307-
this.state.scope,
303+
this.state.context,
308304
mutationFnContext,
309305
)
310306
throw error
@@ -340,8 +336,7 @@ export class Mutation<
340336
case 'pending':
341337
return {
342338
...state,
343-
context: action.scope,
344-
scope: action.scope,
339+
context: action.context,
345340
data: undefined,
346341
failureCount: 0,
347342
failureReason: null,
@@ -396,7 +391,6 @@ export function getDefaultState<
396391
>(): MutationState<TData, TError, TVariables, TOnMutateResult> {
397392
return {
398393
context: undefined,
399-
scope: undefined,
400394
data: undefined,
401395
error: null,
402396
failureCount: 0,

packages/query-core/src/mutationObserver.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ export class MutationObserver<
163163
// First trigger the mutate callbacks
164164
if (this.#mutateOptions && this.hasListeners()) {
165165
const variables = this.#currentResult.variables!
166-
const scope = this.#currentResult.scope
166+
const scope = this.#currentResult.context
167167

168168
const context = {
169169
client: this.#client,

packages/query-devtools/src/Devtools.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2427,7 +2427,7 @@ const MutationDetails = () => {
24272427
<Explorer
24282428
label="Context"
24292429
defaultExpanded={['Context']}
2430-
value={activeMutation()!.state.scope}
2430+
value={activeMutation()!.state.context}
24312431
/>
24322432
</div>
24332433
<div class={cx(styles().detailsHeader, 'tsqd-query-details-header')}>

0 commit comments

Comments
 (0)