@tanstack/query-core 4.29.23 → 4.30.0
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/lib/focusManager.d.ts.map +1 -0
- package/build/lib/hydration.d.ts.map +1 -0
- package/build/lib/index.d.ts.map +1 -0
- package/build/lib/infiniteQueryBehavior.d.ts.map +1 -0
- package/build/lib/infiniteQueryObserver.d.ts +1 -1
- package/build/lib/infiniteQueryObserver.d.ts.map +1 -0
- package/build/lib/infiniteQueryObserver.esm.js.map +1 -1
- package/build/lib/infiniteQueryObserver.js.map +1 -1
- package/build/lib/infiniteQueryObserver.mjs.map +1 -1
- package/build/lib/logger.d.ts.map +1 -0
- package/build/lib/logger.native.d.ts.map +1 -0
- package/build/lib/mutation.d.ts +2 -2
- package/build/lib/mutation.d.ts.map +1 -0
- package/build/lib/mutation.esm.js.map +1 -1
- package/build/lib/mutation.js.map +1 -1
- package/build/lib/mutation.mjs.map +1 -1
- package/build/lib/mutationCache.d.ts +2 -2
- package/build/lib/mutationCache.d.ts.map +1 -0
- package/build/lib/mutationCache.esm.js.map +1 -1
- package/build/lib/mutationCache.js.map +1 -1
- package/build/lib/mutationCache.mjs.map +1 -1
- package/build/lib/mutationObserver.d.ts +3 -3
- package/build/lib/mutationObserver.d.ts.map +1 -0
- package/build/lib/mutationObserver.esm.js.map +1 -1
- package/build/lib/mutationObserver.js.map +1 -1
- package/build/lib/mutationObserver.mjs.map +1 -1
- package/build/lib/notifyManager.d.ts.map +1 -0
- package/build/lib/onlineManager.d.ts.map +1 -0
- package/build/lib/queriesObserver.d.ts +2 -2
- package/build/lib/queriesObserver.d.ts.map +1 -0
- package/build/lib/queriesObserver.esm.js.map +1 -1
- package/build/lib/queriesObserver.js.map +1 -1
- package/build/lib/queriesObserver.mjs.map +1 -1
- package/build/lib/query.d.ts +2 -2
- package/build/lib/query.d.ts.map +1 -0
- package/build/lib/query.esm.js.map +1 -1
- package/build/lib/query.js.map +1 -1
- package/build/lib/query.mjs.map +1 -1
- package/build/lib/queryCache.d.ts +2 -2
- package/build/lib/queryCache.d.ts.map +1 -0
- package/build/lib/queryCache.esm.js.map +1 -1
- package/build/lib/queryCache.js.map +1 -1
- package/build/lib/queryCache.mjs.map +1 -1
- package/build/lib/queryClient.d.ts +3 -3
- package/build/lib/queryClient.d.ts.map +1 -0
- package/build/lib/queryClient.esm.js.map +1 -1
- package/build/lib/queryClient.js.map +1 -1
- package/build/lib/queryClient.mjs.map +1 -1
- package/build/lib/queryObserver.d.ts +3 -3
- package/build/lib/queryObserver.d.ts.map +1 -0
- package/build/lib/queryObserver.esm.js +3 -2
- package/build/lib/queryObserver.esm.js.map +1 -1
- package/build/lib/queryObserver.js +3 -2
- package/build/lib/queryObserver.js.map +1 -1
- package/build/lib/queryObserver.mjs +3 -2
- package/build/lib/queryObserver.mjs.map +1 -1
- package/build/lib/removable.d.ts.map +1 -0
- package/build/lib/retryer.d.ts.map +1 -0
- package/build/lib/subscribable.d.ts.map +1 -0
- package/build/lib/tests/focusManager.test.d.ts.map +1 -0
- package/build/lib/tests/hydration.test.d.ts.map +1 -0
- package/build/lib/tests/infiniteQueryBehavior.test.d.ts.map +1 -0
- package/build/lib/tests/infiniteQueryObserver.test.d.ts.map +1 -0
- package/build/lib/tests/mutationCache.test.d.ts.map +1 -0
- package/build/lib/tests/mutationObserver.test.d.ts.map +1 -0
- package/build/lib/tests/mutations.test.d.ts.map +1 -0
- package/build/lib/tests/notifyManager.test.d.ts.map +1 -0
- package/build/lib/tests/onlineManager.test.d.ts.map +1 -0
- package/build/lib/tests/queriesObserver.test.d.ts.map +1 -0
- package/build/lib/tests/query.test.d.ts.map +1 -0
- package/build/lib/tests/queryCache.test.d.ts.map +1 -0
- package/build/lib/tests/queryClient.test.d.ts.map +1 -0
- package/build/lib/tests/queryObserver.test.d.ts.map +1 -0
- package/build/lib/tests/utils.d.ts +1 -1
- package/build/lib/tests/utils.d.ts.map +1 -0
- package/build/lib/tests/utils.test.d.ts.map +1 -0
- package/build/lib/types.d.ts +5 -3
- package/build/lib/types.d.ts.map +1 -0
- package/build/lib/utils.d.ts.map +1 -0
- package/build/umd/index.development.js +3 -2
- package/build/umd/index.development.js.map +1 -1
- package/build/umd/index.production.js +1 -1
- package/build/umd/index.production.js.map +1 -1
- package/package.json +1 -1
- package/src/infiniteQueryObserver.ts +6 -6
- package/src/mutation.ts +5 -5
- package/src/mutationCache.ts +4 -4
- package/src/mutationObserver.ts +4 -4
- package/src/queriesObserver.ts +3 -3
- package/src/query.ts +8 -8
- package/src/queryCache.ts +4 -4
- package/src/queryClient.ts +14 -14
- package/src/queryObserver.ts +14 -8
- package/src/tests/hydration.test.tsx +2 -2
- package/src/tests/infiniteQueryBehavior.test.tsx +3 -3
- package/src/tests/infiniteQueryObserver.test.tsx +1 -1
- package/src/tests/mutationCache.test.tsx +1 -1
- package/src/tests/mutationObserver.test.tsx +1 -1
- package/src/tests/mutations.test.tsx +3 -3
- package/src/tests/queriesObserver.test.tsx +2 -2
- package/src/tests/query.test.tsx +6 -6
- package/src/tests/queryCache.test.tsx +3 -3
- package/src/tests/queryClient.test.tsx +4 -4
- package/src/tests/queryObserver.test.tsx +4 -4
- package/src/tests/utils.test.tsx +4 -4
- package/src/tests/utils.ts +1 -1
- package/src/types.ts +9 -3
package/package.json
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
import { QueryObserver } from './queryObserver'
|
|
2
|
+
import {
|
|
3
|
+
hasNextPage,
|
|
4
|
+
hasPreviousPage,
|
|
5
|
+
infiniteQueryBehavior,
|
|
6
|
+
} from './infiniteQueryBehavior'
|
|
1
7
|
import type {
|
|
2
8
|
DefaultedInfiniteQueryObserverOptions,
|
|
3
9
|
FetchNextPageOptions,
|
|
@@ -9,12 +15,6 @@ import type {
|
|
|
9
15
|
} from './types'
|
|
10
16
|
import type { QueryClient } from './queryClient'
|
|
11
17
|
import type { NotifyOptions, ObserverFetchOptions } from './queryObserver'
|
|
12
|
-
import { QueryObserver } from './queryObserver'
|
|
13
|
-
import {
|
|
14
|
-
hasNextPage,
|
|
15
|
-
hasPreviousPage,
|
|
16
|
-
infiniteQueryBehavior,
|
|
17
|
-
} from './infiniteQueryBehavior'
|
|
18
18
|
import type { Query } from './query'
|
|
19
19
|
|
|
20
20
|
type InfiniteQueryObserverListener<TData, TError> = (
|
package/src/mutation.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import type { MutationOptions, MutationStatus, MutationMeta } from './types'
|
|
2
|
-
import type { MutationCache } from './mutationCache'
|
|
3
|
-
import type { MutationObserver } from './mutationObserver'
|
|
4
|
-
import type { Logger } from './logger'
|
|
5
1
|
import { defaultLogger } from './logger'
|
|
6
2
|
import { notifyManager } from './notifyManager'
|
|
7
3
|
import { Removable } from './removable'
|
|
8
|
-
import type { Retryer } from './retryer'
|
|
9
4
|
import { canFetch, createRetryer } from './retryer'
|
|
5
|
+
import type { MutationMeta, MutationOptions, MutationStatus } from './types'
|
|
6
|
+
import type { MutationCache } from './mutationCache'
|
|
7
|
+
import type { MutationObserver } from './mutationObserver'
|
|
8
|
+
import type { Logger } from './logger'
|
|
9
|
+
import type { Retryer } from './retryer'
|
|
10
10
|
|
|
11
11
|
// TYPES
|
|
12
12
|
|
package/src/mutationCache.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
+
import { notifyManager } from './notifyManager'
|
|
2
|
+
import { Mutation } from './mutation'
|
|
3
|
+
import { matchMutation, noop } from './utils'
|
|
4
|
+
import { Subscribable } from './subscribable'
|
|
1
5
|
import type { MutationObserver } from './mutationObserver'
|
|
2
6
|
import type { MutationOptions, NotifyEvent } from './types'
|
|
3
7
|
import type { QueryClient } from './queryClient'
|
|
4
|
-
import { notifyManager } from './notifyManager'
|
|
5
8
|
import type { Action, MutationState } from './mutation'
|
|
6
|
-
import { Mutation } from './mutation'
|
|
7
9
|
import type { MutationFilters } from './utils'
|
|
8
|
-
import { matchMutation, noop } from './utils'
|
|
9
|
-
import { Subscribable } from './subscribable'
|
|
10
10
|
|
|
11
11
|
// TYPES
|
|
12
12
|
|
package/src/mutationObserver.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import type { Action, Mutation } from './mutation'
|
|
2
1
|
import { getDefaultState } from './mutation'
|
|
3
2
|
import { notifyManager } from './notifyManager'
|
|
4
|
-
import type { QueryClient } from './queryClient'
|
|
5
3
|
import { Subscribable } from './subscribable'
|
|
4
|
+
import { shallowEqualObjects } from './utils'
|
|
5
|
+
import type { QueryClient } from './queryClient'
|
|
6
6
|
import type {
|
|
7
7
|
MutateOptions,
|
|
8
8
|
MutationObserverBaseResult,
|
|
9
|
-
MutationObserverResult,
|
|
10
9
|
MutationObserverOptions,
|
|
10
|
+
MutationObserverResult,
|
|
11
11
|
} from './types'
|
|
12
|
-
import {
|
|
12
|
+
import type { Action, Mutation } from './mutation'
|
|
13
13
|
|
|
14
14
|
// TYPES
|
|
15
15
|
|
package/src/queriesObserver.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { difference, replaceAt } from './utils'
|
|
2
2
|
import { notifyManager } from './notifyManager'
|
|
3
|
+
import { QueryObserver } from './queryObserver'
|
|
4
|
+
import { Subscribable } from './subscribable'
|
|
3
5
|
import type {
|
|
6
|
+
DefaultedQueryObserverOptions,
|
|
4
7
|
QueryObserverOptions,
|
|
5
8
|
QueryObserverResult,
|
|
6
|
-
DefaultedQueryObserverOptions,
|
|
7
9
|
} from './types'
|
|
8
10
|
import type { QueryClient } from './queryClient'
|
|
9
11
|
import type { NotifyOptions } from './queryObserver'
|
|
10
|
-
import { QueryObserver } from './queryObserver'
|
|
11
|
-
import { Subscribable } from './subscribable'
|
|
12
12
|
|
|
13
13
|
type QueriesObserverListener = (result: QueryObserverResult[]) => void
|
|
14
14
|
|
package/src/query.ts
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
import { getAbortController, noop, replaceData, timeUntilStale } from './utils'
|
|
2
|
+
import { defaultLogger } from './logger'
|
|
3
|
+
import { notifyManager } from './notifyManager'
|
|
4
|
+
import { canFetch, createRetryer, isCancelledError } from './retryer'
|
|
5
|
+
import { Removable } from './removable'
|
|
2
6
|
import type {
|
|
7
|
+
CancelOptions,
|
|
8
|
+
FetchStatus,
|
|
3
9
|
InitialDataFunction,
|
|
10
|
+
QueryFunctionContext,
|
|
4
11
|
QueryKey,
|
|
12
|
+
QueryMeta,
|
|
5
13
|
QueryOptions,
|
|
6
14
|
QueryStatus,
|
|
7
|
-
QueryFunctionContext,
|
|
8
|
-
QueryMeta,
|
|
9
|
-
CancelOptions,
|
|
10
15
|
SetDataOptions,
|
|
11
|
-
FetchStatus,
|
|
12
16
|
} from './types'
|
|
13
17
|
import type { QueryCache } from './queryCache'
|
|
14
18
|
import type { QueryObserver } from './queryObserver'
|
|
15
19
|
import type { Logger } from './logger'
|
|
16
|
-
import { defaultLogger } from './logger'
|
|
17
|
-
import { notifyManager } from './notifyManager'
|
|
18
20
|
import type { Retryer } from './retryer'
|
|
19
|
-
import { isCancelledError, canFetch, createRetryer } from './retryer'
|
|
20
|
-
import { Removable } from './removable'
|
|
21
21
|
|
|
22
22
|
// TYPES
|
|
23
23
|
|
package/src/queryCache.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type { QueryFilters } from './utils'
|
|
2
1
|
import { hashQueryKeyByOptions, matchQuery, parseFilterArgs } from './utils'
|
|
3
|
-
import type { Action, QueryState } from './query'
|
|
4
2
|
import { Query } from './query'
|
|
5
|
-
import type { NotifyEvent, QueryKey, QueryOptions } from './types'
|
|
6
3
|
import { notifyManager } from './notifyManager'
|
|
7
|
-
import type { QueryClient } from './queryClient'
|
|
8
4
|
import { Subscribable } from './subscribable'
|
|
5
|
+
import type { QueryFilters } from './utils'
|
|
6
|
+
import type { Action, QueryState } from './query'
|
|
7
|
+
import type { NotifyEvent, QueryKey, QueryOptions } from './types'
|
|
8
|
+
import type { QueryClient } from './queryClient'
|
|
9
9
|
import type { QueryObserver } from './queryObserver'
|
|
10
10
|
|
|
11
11
|
// TYPES
|
package/src/queryClient.ts
CHANGED
|
@@ -1,15 +1,23 @@
|
|
|
1
|
-
import type { QueryFilters, Updater, MutationFilters } from './utils'
|
|
2
1
|
import {
|
|
2
|
+
functionalUpdate,
|
|
3
3
|
hashQueryKey,
|
|
4
|
+
hashQueryKeyByOptions,
|
|
4
5
|
noop,
|
|
5
6
|
parseFilterArgs,
|
|
6
7
|
parseQueryArgs,
|
|
7
8
|
partialMatchKey,
|
|
8
|
-
hashQueryKeyByOptions,
|
|
9
|
-
functionalUpdate,
|
|
10
9
|
} from './utils'
|
|
10
|
+
import { QueryCache } from './queryCache'
|
|
11
|
+
import { MutationCache } from './mutationCache'
|
|
12
|
+
import { focusManager } from './focusManager'
|
|
13
|
+
import { onlineManager } from './onlineManager'
|
|
14
|
+
import { notifyManager } from './notifyManager'
|
|
15
|
+
import { infiniteQueryBehavior } from './infiniteQueryBehavior'
|
|
16
|
+
import { defaultLogger } from './logger'
|
|
17
|
+
import type { CancelOptions, DefaultedQueryObserverOptions } from './types'
|
|
18
|
+
import type { Logger } from './logger'
|
|
19
|
+
import type { QueryState } from './query'
|
|
11
20
|
import type {
|
|
12
|
-
QueryClientConfig,
|
|
13
21
|
DefaultOptions,
|
|
14
22
|
FetchInfiniteQueryOptions,
|
|
15
23
|
FetchQueryOptions,
|
|
@@ -19,6 +27,7 @@ import type {
|
|
|
19
27
|
MutationKey,
|
|
20
28
|
MutationObserverOptions,
|
|
21
29
|
MutationOptions,
|
|
30
|
+
QueryClientConfig,
|
|
22
31
|
QueryFunction,
|
|
23
32
|
QueryKey,
|
|
24
33
|
QueryObserverOptions,
|
|
@@ -30,16 +39,7 @@ import type {
|
|
|
30
39
|
SetDataOptions,
|
|
31
40
|
WithRequired,
|
|
32
41
|
} from './types'
|
|
33
|
-
import type {
|
|
34
|
-
import { QueryCache } from './queryCache'
|
|
35
|
-
import { MutationCache } from './mutationCache'
|
|
36
|
-
import { focusManager } from './focusManager'
|
|
37
|
-
import { onlineManager } from './onlineManager'
|
|
38
|
-
import { notifyManager } from './notifyManager'
|
|
39
|
-
import { infiniteQueryBehavior } from './infiniteQueryBehavior'
|
|
40
|
-
import type { CancelOptions, DefaultedQueryObserverOptions } from './types'
|
|
41
|
-
import type { Logger } from './logger'
|
|
42
|
-
import { defaultLogger } from './logger'
|
|
42
|
+
import type { MutationFilters, QueryFilters, Updater } from './utils'
|
|
43
43
|
|
|
44
44
|
// TYPES
|
|
45
45
|
|
package/src/queryObserver.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { DefaultedQueryObserverOptions, RefetchPageFilters } from './types'
|
|
2
1
|
import {
|
|
3
2
|
isServer,
|
|
4
3
|
isValidTimeout,
|
|
@@ -8,6 +7,9 @@ import {
|
|
|
8
7
|
timeUntilStale,
|
|
9
8
|
} from './utils'
|
|
10
9
|
import { notifyManager } from './notifyManager'
|
|
10
|
+
import { focusManager } from './focusManager'
|
|
11
|
+
import { Subscribable } from './subscribable'
|
|
12
|
+
import { canFetch, isCancelledError } from './retryer'
|
|
11
13
|
import type {
|
|
12
14
|
PlaceholderDataFunction,
|
|
13
15
|
QueryKey,
|
|
@@ -17,11 +19,9 @@ import type {
|
|
|
17
19
|
QueryOptions,
|
|
18
20
|
RefetchOptions,
|
|
19
21
|
} from './types'
|
|
20
|
-
import type {
|
|
22
|
+
import type { Action, FetchOptions, Query, QueryState } from './query'
|
|
21
23
|
import type { QueryClient } from './queryClient'
|
|
22
|
-
import {
|
|
23
|
-
import { Subscribable } from './subscribable'
|
|
24
|
-
import { canFetch, isCancelledError } from './retryer'
|
|
24
|
+
import type { DefaultedQueryObserverOptions, RefetchPageFilters } from './types'
|
|
25
25
|
|
|
26
26
|
type QueryObserverListener<TData, TError> = (
|
|
27
27
|
result: QueryObserverResult<TData, TError>,
|
|
@@ -637,15 +637,21 @@ export class QueryObserver<
|
|
|
637
637
|
}
|
|
638
638
|
|
|
639
639
|
const { notifyOnChangeProps } = this.options
|
|
640
|
+
const notifyOnChangePropsValue =
|
|
641
|
+
typeof notifyOnChangeProps === 'function'
|
|
642
|
+
? notifyOnChangeProps()
|
|
643
|
+
: notifyOnChangeProps
|
|
640
644
|
|
|
641
645
|
if (
|
|
642
|
-
|
|
643
|
-
(!
|
|
646
|
+
notifyOnChangePropsValue === 'all' ||
|
|
647
|
+
(!notifyOnChangePropsValue && !this.trackedProps.size)
|
|
644
648
|
) {
|
|
645
649
|
return true
|
|
646
650
|
}
|
|
647
651
|
|
|
648
|
-
const includedProps = new Set(
|
|
652
|
+
const includedProps = new Set(
|
|
653
|
+
notifyOnChangePropsValue ?? this.trackedProps,
|
|
654
|
+
)
|
|
649
655
|
|
|
650
656
|
if (this.options.useErrorBoundary) {
|
|
651
657
|
includedProps.add('error')
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
+
import { QueryCache } from '../queryCache'
|
|
2
|
+
import { dehydrate, hydrate } from '../hydration'
|
|
1
3
|
import {
|
|
2
4
|
createQueryClient,
|
|
3
5
|
executeMutation,
|
|
4
6
|
mockNavigatorOnLine,
|
|
5
7
|
sleep,
|
|
6
8
|
} from './utils'
|
|
7
|
-
import { QueryCache } from '../queryCache'
|
|
8
|
-
import { dehydrate, hydrate } from '../hydration'
|
|
9
9
|
|
|
10
10
|
async function fetchData<TData>(value: TData, ms?: number): Promise<TData> {
|
|
11
11
|
await sleep(ms || 0)
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { waitFor } from '@testing-library/react'
|
|
2
|
+
import { InfiniteQueryObserver } from '@tanstack/query-core'
|
|
3
|
+
import { createQueryClient, queryKey } from './utils'
|
|
2
4
|
import type {
|
|
3
|
-
QueryClient,
|
|
4
5
|
InfiniteQueryObserverResult,
|
|
5
6
|
QueryCache,
|
|
7
|
+
QueryClient,
|
|
6
8
|
} from '@tanstack/query-core'
|
|
7
|
-
import { InfiniteQueryObserver } from '@tanstack/query-core'
|
|
8
|
-
import { createQueryClient, queryKey } from './utils'
|
|
9
9
|
|
|
10
10
|
describe('InfiniteQueryBehavior', () => {
|
|
11
11
|
let queryClient: QueryClient
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { waitFor } from '@testing-library/react'
|
|
2
|
-
import { queryKey, sleep, executeMutation, createQueryClient } from './utils'
|
|
3
2
|
import { MutationCache, MutationObserver } from '..'
|
|
3
|
+
import { createQueryClient, executeMutation, queryKey, sleep } from './utils'
|
|
4
4
|
|
|
5
5
|
describe('mutationCache', () => {
|
|
6
6
|
describe('MutationCacheConfig error callbacks', () => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { waitFor } from '@testing-library/react'
|
|
2
|
+
import { MutationObserver } from '..'
|
|
2
3
|
import { createQueryClient, sleep } from './utils'
|
|
3
4
|
import type { QueryClient } from '..'
|
|
4
|
-
import { MutationObserver } from '..'
|
|
5
5
|
|
|
6
6
|
describe('mutationObserver', () => {
|
|
7
7
|
let queryClient: QueryClient
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { waitFor } from '@testing-library/react'
|
|
2
|
+
import { MutationObserver } from '../mutationObserver'
|
|
2
3
|
import { createQueryClient, executeMutation, queryKey, sleep } from './utils'
|
|
4
|
+
import type { QueryClient } from '..'
|
|
3
5
|
import type { MutationState } from '../mutation'
|
|
4
|
-
import { MutationObserver } from '../mutationObserver'
|
|
5
|
-
import { waitFor } from '@testing-library/react'
|
|
6
6
|
|
|
7
7
|
describe('mutations', () => {
|
|
8
8
|
let queryClient: QueryClient
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { waitFor } from '@testing-library/react'
|
|
2
|
-
import { sleep, queryKey, createQueryClient, mockLogger } from './utils'
|
|
3
|
-
import type { QueryClient, QueryObserverResult } from '..'
|
|
4
2
|
import { QueriesObserver, QueryObserver } from '..'
|
|
3
|
+
import { createQueryClient, mockLogger, queryKey, sleep } from './utils'
|
|
4
|
+
import type { QueryClient, QueryObserverResult } from '..'
|
|
5
5
|
import type { QueryKey } from '..'
|
|
6
6
|
|
|
7
7
|
describe('queriesObserver', () => {
|
package/src/tests/query.test.tsx
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import { waitFor } from '@testing-library/react'
|
|
2
|
+
import { QueryObserver, isCancelledError, isError, onlineManager } from '..'
|
|
1
3
|
import {
|
|
2
|
-
sleep,
|
|
3
|
-
queryKey,
|
|
4
|
-
mockVisibilityState,
|
|
5
|
-
mockLogger,
|
|
6
4
|
createQueryClient,
|
|
5
|
+
mockLogger,
|
|
6
|
+
mockVisibilityState,
|
|
7
|
+
queryKey,
|
|
8
|
+
sleep,
|
|
7
9
|
} from './utils'
|
|
8
10
|
import type {
|
|
9
11
|
QueryCache,
|
|
@@ -11,8 +13,6 @@ import type {
|
|
|
11
13
|
QueryFunctionContext,
|
|
12
14
|
QueryObserverResult,
|
|
13
15
|
} from '..'
|
|
14
|
-
import { QueryObserver, isCancelledError, isError, onlineManager } from '..'
|
|
15
|
-
import { waitFor } from '@testing-library/react'
|
|
16
16
|
|
|
17
17
|
describe('query', () => {
|
|
18
18
|
let queryClient: QueryClient
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type { QueryClient } from '..'
|
|
1
|
+
import { waitFor } from '@testing-library/react'
|
|
3
2
|
import { QueryCache, QueryObserver } from '..'
|
|
3
|
+
import { createQueryClient, queryKey, sleep } from './utils'
|
|
4
|
+
import type { QueryClient } from '..'
|
|
4
5
|
import type { Query } from '.././query'
|
|
5
|
-
import { waitFor } from '@testing-library/react'
|
|
6
6
|
|
|
7
7
|
describe('queryCache', () => {
|
|
8
8
|
let queryClient: QueryClient
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { waitFor } from '@testing-library/react'
|
|
2
2
|
import '@testing-library/jest-dom'
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import { InfiniteQueryObserver, MutationObserver, QueryObserver } from '..'
|
|
5
|
+
import { focusManager, onlineManager } from '..'
|
|
6
|
+
import { noop } from '../utils'
|
|
7
|
+
import { createQueryClient, mockLogger, queryKey, sleep } from './utils'
|
|
5
8
|
import type {
|
|
6
9
|
QueryCache,
|
|
7
10
|
QueryClient,
|
|
8
11
|
QueryFunction,
|
|
9
12
|
QueryObserverOptions,
|
|
10
13
|
} from '..'
|
|
11
|
-
import { InfiniteQueryObserver, MutationObserver, QueryObserver } from '..'
|
|
12
|
-
import { focusManager, onlineManager } from '..'
|
|
13
|
-
import { noop } from '../utils'
|
|
14
14
|
|
|
15
15
|
describe('queryClient', () => {
|
|
16
16
|
let queryClient: QueryClient
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
+
import { QueryObserver, focusManager } from '..'
|
|
1
2
|
import {
|
|
2
|
-
|
|
3
|
-
queryKey,
|
|
3
|
+
createQueryClient,
|
|
4
4
|
expectType,
|
|
5
5
|
mockLogger,
|
|
6
|
-
|
|
6
|
+
queryKey,
|
|
7
|
+
sleep,
|
|
7
8
|
} from './utils'
|
|
8
9
|
import type { QueryClient, QueryObserverResult } from '..'
|
|
9
|
-
import { QueryObserver, focusManager } from '..'
|
|
10
10
|
|
|
11
11
|
describe('queryObserver', () => {
|
|
12
12
|
let queryClient: QueryClient
|
package/src/tests/utils.test.tsx
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
partialDeepEqual,
|
|
2
|
+
isPlainArray,
|
|
4
3
|
isPlainObject,
|
|
5
|
-
parseMutationArgs,
|
|
6
4
|
matchMutation,
|
|
5
|
+
parseMutationArgs,
|
|
6
|
+
partialDeepEqual,
|
|
7
|
+
replaceEqualDeep,
|
|
7
8
|
scheduleMicrotask,
|
|
8
9
|
sleep,
|
|
9
|
-
isPlainArray,
|
|
10
10
|
} from '../utils'
|
|
11
11
|
import { Mutation } from '../mutation'
|
|
12
12
|
import { createQueryClient } from './utils'
|
package/src/tests/utils.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { act } from '@testing-library/react'
|
|
2
2
|
|
|
3
|
-
import type { MutationOptions, QueryClientConfig } from '@tanstack/query-core'
|
|
4
3
|
import { QueryClient } from '@tanstack/query-core'
|
|
5
4
|
import * as utils from '../utils'
|
|
5
|
+
import type { MutationOptions, QueryClientConfig } from '@tanstack/query-core'
|
|
6
6
|
|
|
7
7
|
export function createQueryClient(config?: QueryClientConfig): QueryClient {
|
|
8
8
|
jest.spyOn(console, 'error').mockImplementation(() => undefined)
|
package/src/types.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/* istanbul ignore file */
|
|
2
2
|
|
|
3
3
|
import type { MutationState } from './mutation'
|
|
4
|
-
import type {
|
|
5
|
-
import type {
|
|
4
|
+
import type { Query, QueryBehavior } from './query'
|
|
5
|
+
import type { RetryDelayValue, RetryValue } from './retryer'
|
|
6
6
|
import type { QueryFilters, QueryTypeFilter } from './utils'
|
|
7
7
|
import type { QueryCache } from './queryCache'
|
|
8
8
|
import type { MutationCache } from './mutationCache'
|
|
@@ -55,6 +55,11 @@ export interface QueryMeta {
|
|
|
55
55
|
|
|
56
56
|
export type NetworkMode = 'online' | 'always' | 'offlineFirst'
|
|
57
57
|
|
|
58
|
+
export type NotifyOnChangeProps =
|
|
59
|
+
| Array<keyof InfiniteQueryObserverResult>
|
|
60
|
+
| 'all'
|
|
61
|
+
| (() => Array<keyof InfiniteQueryObserverResult> | 'all')
|
|
62
|
+
|
|
58
63
|
export interface QueryOptions<
|
|
59
64
|
TQueryFnData = unknown,
|
|
60
65
|
TError = unknown,
|
|
@@ -200,9 +205,10 @@ export interface QueryObserverOptions<
|
|
|
200
205
|
* If set, the component will only re-render if any of the listed properties change.
|
|
201
206
|
* When set to `['data', 'error']`, the component will only re-render when the `data` or `error` properties change.
|
|
202
207
|
* When set to `'all'`, the component will re-render whenever a query is updated.
|
|
208
|
+
* When set to a function, the function will be executed to compute the list of properties.
|
|
203
209
|
* By default, access to properties will be tracked, and the component will only re-render when one of the tracked properties change.
|
|
204
210
|
*/
|
|
205
|
-
notifyOnChangeProps?:
|
|
211
|
+
notifyOnChangeProps?: NotifyOnChangeProps
|
|
206
212
|
/**
|
|
207
213
|
* This callback will fire any time the query successfully fetches new data.
|
|
208
214
|
*
|