@tanstack/query-core 5.79.1 → 5.79.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/legacy/infiniteQueryBehavior.cjs +12 -10
- package/build/legacy/infiniteQueryBehavior.cjs.map +1 -1
- package/build/legacy/infiniteQueryBehavior.js +12 -10
- package/build/legacy/infiniteQueryBehavior.js.map +1 -1
- package/build/legacy/query.cjs +22 -17
- package/build/legacy/query.cjs.map +1 -1
- package/build/legacy/query.js +22 -17
- package/build/legacy/query.js.map +1 -1
- package/build/modern/infiniteQueryBehavior.cjs +12 -10
- package/build/modern/infiniteQueryBehavior.cjs.map +1 -1
- package/build/modern/infiniteQueryBehavior.js +12 -10
- package/build/modern/infiniteQueryBehavior.js.map +1 -1
- package/build/modern/query.cjs +22 -17
- package/build/modern/query.cjs.map +1 -1
- package/build/modern/query.js +22 -17
- package/build/modern/query.js.map +1 -1
- package/package.json +1 -1
- package/src/infiniteQueryBehavior.ts +15 -13
- package/src/query.ts +37 -27
package/src/query.ts
CHANGED
|
@@ -18,7 +18,6 @@ import type {
|
|
|
18
18
|
FetchStatus,
|
|
19
19
|
InitialDataFunction,
|
|
20
20
|
OmitKeyof,
|
|
21
|
-
QueryFunction,
|
|
22
21
|
QueryFunctionContext,
|
|
23
22
|
QueryKey,
|
|
24
23
|
QueryMeta,
|
|
@@ -431,48 +430,59 @@ export class Query<
|
|
|
431
430
|
const queryFn = ensureQueryFn(this.options, fetchOptions)
|
|
432
431
|
|
|
433
432
|
// Create query function context
|
|
434
|
-
const
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
433
|
+
const createQueryFnContext = (): QueryFunctionContext<TQueryKey> => {
|
|
434
|
+
const queryFnContext: OmitKeyof<
|
|
435
|
+
QueryFunctionContext<TQueryKey>,
|
|
436
|
+
'signal'
|
|
437
|
+
> = {
|
|
438
|
+
client: this.#client,
|
|
439
|
+
queryKey: this.queryKey,
|
|
440
|
+
meta: this.meta,
|
|
441
|
+
}
|
|
442
|
+
addSignalProperty(queryFnContext)
|
|
443
|
+
return queryFnContext as QueryFunctionContext<TQueryKey>
|
|
441
444
|
}
|
|
442
445
|
|
|
443
|
-
|
|
446
|
+
const queryFnContext = createQueryFnContext()
|
|
444
447
|
|
|
445
448
|
this.#abortSignalConsumed = false
|
|
446
449
|
if (this.options.persister) {
|
|
447
450
|
return this.options.persister(
|
|
448
|
-
queryFn
|
|
449
|
-
queryFnContext
|
|
451
|
+
queryFn,
|
|
452
|
+
queryFnContext,
|
|
450
453
|
this as unknown as Query,
|
|
451
454
|
)
|
|
452
455
|
}
|
|
453
456
|
|
|
454
|
-
return queryFn(queryFnContext
|
|
457
|
+
return queryFn(queryFnContext)
|
|
455
458
|
}
|
|
456
459
|
|
|
457
460
|
// Trigger behavior hook
|
|
458
|
-
const
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
461
|
+
const createFetchContext = (): FetchContext<
|
|
462
|
+
TQueryFnData,
|
|
463
|
+
TError,
|
|
464
|
+
TData,
|
|
465
|
+
TQueryKey
|
|
466
|
+
> => {
|
|
467
|
+
const context: OmitKeyof<
|
|
468
|
+
FetchContext<TQueryFnData, TError, TData, TQueryKey>,
|
|
469
|
+
'signal'
|
|
470
|
+
> = {
|
|
471
|
+
fetchOptions,
|
|
472
|
+
options: this.options,
|
|
473
|
+
queryKey: this.queryKey,
|
|
474
|
+
client: this.#client,
|
|
475
|
+
state: this.state,
|
|
476
|
+
fetchFn,
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
addSignalProperty(context)
|
|
480
|
+
return context as FetchContext<TQueryFnData, TError, TData, TQueryKey>
|
|
468
481
|
}
|
|
469
482
|
|
|
470
|
-
|
|
483
|
+
const context = createFetchContext()
|
|
471
484
|
|
|
472
|
-
this.options.behavior?.onFetch(
|
|
473
|
-
context as FetchContext<TQueryFnData, TError, TData, TQueryKey>,
|
|
474
|
-
this as unknown as Query,
|
|
475
|
-
)
|
|
485
|
+
this.options.behavior?.onFetch(context, this as unknown as Query)
|
|
476
486
|
|
|
477
487
|
// Store state in case the current fetch needs to be reverted
|
|
478
488
|
this.#revertState = this.state
|