@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.
Files changed (107) hide show
  1. package/build/lib/focusManager.d.ts.map +1 -0
  2. package/build/lib/hydration.d.ts.map +1 -0
  3. package/build/lib/index.d.ts.map +1 -0
  4. package/build/lib/infiniteQueryBehavior.d.ts.map +1 -0
  5. package/build/lib/infiniteQueryObserver.d.ts +1 -1
  6. package/build/lib/infiniteQueryObserver.d.ts.map +1 -0
  7. package/build/lib/infiniteQueryObserver.esm.js.map +1 -1
  8. package/build/lib/infiniteQueryObserver.js.map +1 -1
  9. package/build/lib/infiniteQueryObserver.mjs.map +1 -1
  10. package/build/lib/logger.d.ts.map +1 -0
  11. package/build/lib/logger.native.d.ts.map +1 -0
  12. package/build/lib/mutation.d.ts +2 -2
  13. package/build/lib/mutation.d.ts.map +1 -0
  14. package/build/lib/mutation.esm.js.map +1 -1
  15. package/build/lib/mutation.js.map +1 -1
  16. package/build/lib/mutation.mjs.map +1 -1
  17. package/build/lib/mutationCache.d.ts +2 -2
  18. package/build/lib/mutationCache.d.ts.map +1 -0
  19. package/build/lib/mutationCache.esm.js.map +1 -1
  20. package/build/lib/mutationCache.js.map +1 -1
  21. package/build/lib/mutationCache.mjs.map +1 -1
  22. package/build/lib/mutationObserver.d.ts +3 -3
  23. package/build/lib/mutationObserver.d.ts.map +1 -0
  24. package/build/lib/mutationObserver.esm.js.map +1 -1
  25. package/build/lib/mutationObserver.js.map +1 -1
  26. package/build/lib/mutationObserver.mjs.map +1 -1
  27. package/build/lib/notifyManager.d.ts.map +1 -0
  28. package/build/lib/onlineManager.d.ts.map +1 -0
  29. package/build/lib/queriesObserver.d.ts +2 -2
  30. package/build/lib/queriesObserver.d.ts.map +1 -0
  31. package/build/lib/queriesObserver.esm.js.map +1 -1
  32. package/build/lib/queriesObserver.js.map +1 -1
  33. package/build/lib/queriesObserver.mjs.map +1 -1
  34. package/build/lib/query.d.ts +2 -2
  35. package/build/lib/query.d.ts.map +1 -0
  36. package/build/lib/query.esm.js.map +1 -1
  37. package/build/lib/query.js.map +1 -1
  38. package/build/lib/query.mjs.map +1 -1
  39. package/build/lib/queryCache.d.ts +2 -2
  40. package/build/lib/queryCache.d.ts.map +1 -0
  41. package/build/lib/queryCache.esm.js.map +1 -1
  42. package/build/lib/queryCache.js.map +1 -1
  43. package/build/lib/queryCache.mjs.map +1 -1
  44. package/build/lib/queryClient.d.ts +3 -3
  45. package/build/lib/queryClient.d.ts.map +1 -0
  46. package/build/lib/queryClient.esm.js.map +1 -1
  47. package/build/lib/queryClient.js.map +1 -1
  48. package/build/lib/queryClient.mjs.map +1 -1
  49. package/build/lib/queryObserver.d.ts +3 -3
  50. package/build/lib/queryObserver.d.ts.map +1 -0
  51. package/build/lib/queryObserver.esm.js +3 -2
  52. package/build/lib/queryObserver.esm.js.map +1 -1
  53. package/build/lib/queryObserver.js +3 -2
  54. package/build/lib/queryObserver.js.map +1 -1
  55. package/build/lib/queryObserver.mjs +3 -2
  56. package/build/lib/queryObserver.mjs.map +1 -1
  57. package/build/lib/removable.d.ts.map +1 -0
  58. package/build/lib/retryer.d.ts.map +1 -0
  59. package/build/lib/subscribable.d.ts.map +1 -0
  60. package/build/lib/tests/focusManager.test.d.ts.map +1 -0
  61. package/build/lib/tests/hydration.test.d.ts.map +1 -0
  62. package/build/lib/tests/infiniteQueryBehavior.test.d.ts.map +1 -0
  63. package/build/lib/tests/infiniteQueryObserver.test.d.ts.map +1 -0
  64. package/build/lib/tests/mutationCache.test.d.ts.map +1 -0
  65. package/build/lib/tests/mutationObserver.test.d.ts.map +1 -0
  66. package/build/lib/tests/mutations.test.d.ts.map +1 -0
  67. package/build/lib/tests/notifyManager.test.d.ts.map +1 -0
  68. package/build/lib/tests/onlineManager.test.d.ts.map +1 -0
  69. package/build/lib/tests/queriesObserver.test.d.ts.map +1 -0
  70. package/build/lib/tests/query.test.d.ts.map +1 -0
  71. package/build/lib/tests/queryCache.test.d.ts.map +1 -0
  72. package/build/lib/tests/queryClient.test.d.ts.map +1 -0
  73. package/build/lib/tests/queryObserver.test.d.ts.map +1 -0
  74. package/build/lib/tests/utils.d.ts +1 -1
  75. package/build/lib/tests/utils.d.ts.map +1 -0
  76. package/build/lib/tests/utils.test.d.ts.map +1 -0
  77. package/build/lib/types.d.ts +5 -3
  78. package/build/lib/types.d.ts.map +1 -0
  79. package/build/lib/utils.d.ts.map +1 -0
  80. package/build/umd/index.development.js +3 -2
  81. package/build/umd/index.development.js.map +1 -1
  82. package/build/umd/index.production.js +1 -1
  83. package/build/umd/index.production.js.map +1 -1
  84. package/package.json +1 -1
  85. package/src/infiniteQueryObserver.ts +6 -6
  86. package/src/mutation.ts +5 -5
  87. package/src/mutationCache.ts +4 -4
  88. package/src/mutationObserver.ts +4 -4
  89. package/src/queriesObserver.ts +3 -3
  90. package/src/query.ts +8 -8
  91. package/src/queryCache.ts +4 -4
  92. package/src/queryClient.ts +14 -14
  93. package/src/queryObserver.ts +14 -8
  94. package/src/tests/hydration.test.tsx +2 -2
  95. package/src/tests/infiniteQueryBehavior.test.tsx +3 -3
  96. package/src/tests/infiniteQueryObserver.test.tsx +1 -1
  97. package/src/tests/mutationCache.test.tsx +1 -1
  98. package/src/tests/mutationObserver.test.tsx +1 -1
  99. package/src/tests/mutations.test.tsx +3 -3
  100. package/src/tests/queriesObserver.test.tsx +2 -2
  101. package/src/tests/query.test.tsx +6 -6
  102. package/src/tests/queryCache.test.tsx +3 -3
  103. package/src/tests/queryClient.test.tsx +4 -4
  104. package/src/tests/queryObserver.test.tsx +4 -4
  105. package/src/tests/utils.test.tsx +4 -4
  106. package/src/tests/utils.ts +1 -1
  107. package/src/types.ts +9 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanstack/query-core",
3
- "version": "4.29.23",
3
+ "version": "4.30.0",
4
4
  "description": "The framework agnostic core that powers TanStack Query",
5
5
  "author": "tannerlinsley",
6
6
  "license": "MIT",
@@ -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
 
@@ -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
 
@@ -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 { shallowEqualObjects } from './utils'
12
+ import type { Action, Mutation } from './mutation'
13
13
 
14
14
  // TYPES
15
15
 
@@ -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
@@ -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 { QueryState } from './query'
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
 
@@ -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 { Query, QueryState, Action, FetchOptions } from './query'
22
+ import type { Action, FetchOptions, Query, QueryState } from './query'
21
23
  import type { QueryClient } from './queryClient'
22
- import { focusManager } from './focusManager'
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
- notifyOnChangeProps === 'all' ||
643
- (!notifyOnChangeProps && !this.trackedProps.size)
646
+ notifyOnChangePropsValue === 'all' ||
647
+ (!notifyOnChangePropsValue && !this.trackedProps.size)
644
648
  ) {
645
649
  return true
646
650
  }
647
651
 
648
- const includedProps = new Set(notifyOnChangeProps ?? this.trackedProps)
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
+ import { InfiniteQueryObserver } from '..'
1
2
  import { createQueryClient, queryKey, sleep } from './utils'
2
3
  import type { QueryClient } from '..'
3
- import { InfiniteQueryObserver } from '..'
4
4
 
5
5
  describe('InfiniteQueryObserver', () => {
6
6
  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 type { QueryClient } from '..'
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', () => {
@@ -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 { sleep, queryKey, createQueryClient } from './utils'
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 { sleep, queryKey, mockLogger, createQueryClient } from './utils'
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
- sleep,
3
- queryKey,
3
+ createQueryClient,
4
4
  expectType,
5
5
  mockLogger,
6
- createQueryClient,
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
@@ -1,12 +1,12 @@
1
1
  import {
2
- replaceEqualDeep,
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'
@@ -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 { QueryBehavior, Query } from './query'
5
- import type { RetryValue, RetryDelayValue } from './retryer'
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?: Array<keyof InfiniteQueryObserverResult> | 'all'
211
+ notifyOnChangeProps?: NotifyOnChangeProps
206
212
  /**
207
213
  * This callback will fire any time the query successfully fetches new data.
208
214
  *