@tanstack/vue-query 5.72.2 → 5.73.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/legacy/devtools/devtools.d.cts +1 -1
- package/build/legacy/devtools/devtools.d.ts +1 -1
- package/build/legacy/index.d.cts +2 -3
- package/build/legacy/index.d.ts +2 -3
- package/build/legacy/infiniteQueryOptions.d.cts +2 -18
- package/build/legacy/infiniteQueryOptions.d.ts +2 -18
- package/build/legacy/{queryClient-CLLRHvFX.d.cts → queryClient-DKRxpPKC.d.ts} +24 -5
- package/build/{modern/queryClient-CLLRHvFX.d.cts → legacy/queryClient-DjQXZR5U.d.cts} +24 -5
- package/build/legacy/queryClient.cjs.map +1 -1
- package/build/legacy/queryClient.d.cts +1 -1
- package/build/legacy/queryClient.d.ts +1 -1
- package/build/legacy/queryClient.js.map +1 -1
- package/build/legacy/queryOptions.d.cts +1 -1
- package/build/legacy/queryOptions.d.ts +1 -1
- package/build/legacy/types.cjs.map +1 -1
- package/build/legacy/types.d.cts +23 -1
- package/build/legacy/types.d.ts +23 -1
- package/build/legacy/useBaseQuery.d.cts +1 -1
- package/build/legacy/useBaseQuery.d.ts +1 -1
- package/build/legacy/useInfiniteQuery.cjs +1 -0
- package/build/legacy/useInfiniteQuery.cjs.map +1 -1
- package/build/legacy/useInfiniteQuery.d.cts +1 -1
- package/build/legacy/useInfiniteQuery.d.ts +1 -1
- package/build/legacy/useInfiniteQuery.js +1 -0
- package/build/legacy/useInfiniteQuery.js.map +1 -1
- package/build/legacy/useIsFetching.d.cts +1 -1
- package/build/legacy/useIsFetching.d.ts +1 -1
- package/build/legacy/useMutation.cjs.map +1 -1
- package/build/legacy/useMutation.d.cts +4 -1
- package/build/legacy/useMutation.d.ts +4 -1
- package/build/legacy/useMutation.js.map +1 -1
- package/build/legacy/useMutationState.d.cts +1 -1
- package/build/legacy/useMutationState.d.ts +1 -1
- package/build/legacy/useQueries.d.cts +1 -1
- package/build/legacy/useQueries.d.ts +1 -1
- package/build/legacy/useQuery.cjs.map +1 -1
- package/build/legacy/useQuery.d.cts +1 -1
- package/build/legacy/useQuery.d.ts +1 -1
- package/build/legacy/useQuery.js.map +1 -1
- package/build/legacy/useQueryClient.d.cts +1 -1
- package/build/legacy/useQueryClient.d.ts +1 -1
- package/build/legacy/utils.d.cts +1 -0
- package/build/legacy/utils.d.ts +1 -0
- package/build/legacy/vueQueryPlugin.cjs.map +1 -1
- package/build/legacy/vueQueryPlugin.d.cts +3 -3
- package/build/legacy/vueQueryPlugin.d.ts +3 -3
- package/build/legacy/vueQueryPlugin.js.map +1 -1
- package/build/modern/devtools/devtools.d.cts +1 -1
- package/build/modern/devtools/devtools.d.ts +1 -1
- package/build/modern/index.d.cts +2 -3
- package/build/modern/index.d.ts +2 -3
- package/build/modern/infiniteQueryOptions.d.cts +2 -18
- package/build/modern/infiniteQueryOptions.d.ts +2 -18
- package/build/{legacy/queryClient-DLkwTG26.d.ts → modern/queryClient-DKRxpPKC.d.ts} +24 -5
- package/build/modern/{queryClient-DLkwTG26.d.ts → queryClient-DjQXZR5U.d.cts} +24 -5
- package/build/modern/queryClient.cjs.map +1 -1
- package/build/modern/queryClient.d.cts +1 -1
- package/build/modern/queryClient.d.ts +1 -1
- package/build/modern/queryClient.js.map +1 -1
- package/build/modern/queryOptions.d.cts +1 -1
- package/build/modern/queryOptions.d.ts +1 -1
- package/build/modern/types.cjs.map +1 -1
- package/build/modern/types.d.cts +23 -1
- package/build/modern/types.d.ts +23 -1
- package/build/modern/useBaseQuery.d.cts +1 -1
- package/build/modern/useBaseQuery.d.ts +1 -1
- package/build/modern/useInfiniteQuery.cjs +1 -0
- package/build/modern/useInfiniteQuery.cjs.map +1 -1
- package/build/modern/useInfiniteQuery.d.cts +1 -1
- package/build/modern/useInfiniteQuery.d.ts +1 -1
- package/build/modern/useInfiniteQuery.js +1 -0
- package/build/modern/useInfiniteQuery.js.map +1 -1
- package/build/modern/useIsFetching.d.cts +1 -1
- package/build/modern/useIsFetching.d.ts +1 -1
- package/build/modern/useMutation.cjs.map +1 -1
- package/build/modern/useMutation.d.cts +4 -1
- package/build/modern/useMutation.d.ts +4 -1
- package/build/modern/useMutation.js.map +1 -1
- package/build/modern/useMutationState.d.cts +1 -1
- package/build/modern/useMutationState.d.ts +1 -1
- package/build/modern/useQueries.d.cts +1 -1
- package/build/modern/useQueries.d.ts +1 -1
- package/build/modern/useQuery.cjs.map +1 -1
- package/build/modern/useQuery.d.cts +1 -1
- package/build/modern/useQuery.d.ts +1 -1
- package/build/modern/useQuery.js.map +1 -1
- package/build/modern/useQueryClient.d.cts +1 -1
- package/build/modern/useQueryClient.d.ts +1 -1
- package/build/modern/utils.d.cts +1 -0
- package/build/modern/utils.d.ts +1 -0
- package/build/modern/vueQueryPlugin.cjs.map +1 -1
- package/build/modern/vueQueryPlugin.d.cts +3 -3
- package/build/modern/vueQueryPlugin.d.ts +3 -3
- package/build/modern/vueQueryPlugin.js.map +1 -1
- package/package.json +1 -1
- package/src/queryClient.ts +3 -4
- package/src/types.ts +36 -0
- package/src/useInfiniteQuery.ts +85 -34
- package/src/useMutation.ts +3 -0
- package/src/useQuery.ts +3 -0
- package/src/vueQueryPlugin.ts +1 -1
package/build/modern/utils.d.cts
CHANGED
package/build/modern/utils.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/vueQueryPlugin.ts"],"sourcesContent":["import { isVue2 } from 'vue-demi'\nimport { isServer } from '@tanstack/query-core'\n\nimport { QueryClient } from './queryClient'\nimport { getClientKey } from './utils'\nimport { setupDevtools } from './devtools/devtools'\nimport type { QueryClientConfig } from '
|
|
1
|
+
{"version":3,"sources":["../../src/vueQueryPlugin.ts"],"sourcesContent":["import { isVue2 } from 'vue-demi'\nimport { isServer } from '@tanstack/query-core'\n\nimport { QueryClient } from './queryClient'\nimport { getClientKey } from './utils'\nimport { setupDevtools } from './devtools/devtools'\nimport type { QueryClientConfig } from './types'\n\ntype ClientPersister = (client: QueryClient) => [() => void, Promise<void>]\n\ninterface CommonOptions {\n enableDevtoolsV6Plugin?: boolean\n queryClientKey?: string\n clientPersister?: ClientPersister\n clientPersisterOnSuccess?: (client: QueryClient) => void\n}\n\ninterface ConfigOptions extends CommonOptions {\n queryClientConfig?: QueryClientConfig\n}\n\ninterface ClientOptions extends CommonOptions {\n queryClient?: QueryClient\n}\n\nexport type VueQueryPluginOptions = ConfigOptions | ClientOptions\n\nexport const VueQueryPlugin = {\n install: (app: any, options: VueQueryPluginOptions = {}) => {\n const clientKey = getClientKey(options.queryClientKey)\n let client: QueryClient\n\n if ('queryClient' in options && options.queryClient) {\n client = options.queryClient\n } else {\n const clientConfig =\n 'queryClientConfig' in options ? options.queryClientConfig : undefined\n client = new QueryClient(clientConfig)\n }\n\n if (!isServer) {\n client.mount()\n }\n\n let persisterUnmount = () => {\n // noop\n }\n\n if (options.clientPersister) {\n client.isRestoring.value = true\n const [unmount, promise] = options.clientPersister(client)\n persisterUnmount = unmount\n promise.then(() => {\n client.isRestoring.value = false\n options.clientPersisterOnSuccess?.(client)\n })\n }\n\n const cleanup = () => {\n client.unmount()\n persisterUnmount()\n }\n\n if (app.onUnmount) {\n app.onUnmount(cleanup)\n } else {\n const originalUnmount = app.unmount\n app.unmount = function vueQueryUnmount() {\n cleanup()\n originalUnmount()\n }\n }\n\n if (isVue2) {\n app.mixin({\n beforeCreate() {\n // HACK: taken from provide(): https://github.com/vuejs/composition-api/blob/master/src/apis/inject.ts#L30\n if (!this._provided) {\n const provideCache = {}\n Object.defineProperty(this, '_provided', {\n get: () => provideCache,\n set: (v) => Object.assign(provideCache, v),\n })\n }\n\n this._provided[clientKey] = client\n\n if (process.env.NODE_ENV === 'development') {\n if (this === this.$root && options.enableDevtoolsV6Plugin) {\n setupDevtools(this, client)\n }\n }\n },\n })\n } else {\n app.provide(clientKey, client)\n\n if (process.env.NODE_ENV === 'development') {\n if (options.enableDevtoolsV6Plugin) {\n setupDevtools(app, client)\n }\n }\n }\n },\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAAuB;AACvB,wBAAyB;AAEzB,yBAA4B;AAC5B,mBAA6B;AAC7B,sBAA8B;AAsBvB,IAAM,iBAAiB;AAAA,EAC5B,SAAS,CAAC,KAAU,UAAiC,CAAC,MAAM;AAC1D,UAAM,gBAAY,2BAAa,QAAQ,cAAc;AACrD,QAAI;AAEJ,QAAI,iBAAiB,WAAW,QAAQ,aAAa;AACnD,eAAS,QAAQ;AAAA,IACnB,OAAO;AACL,YAAM,eACJ,uBAAuB,UAAU,QAAQ,oBAAoB;AAC/D,eAAS,IAAI,+BAAY,YAAY;AAAA,IACvC;AAEA,QAAI,CAAC,4BAAU;AACb,aAAO,MAAM;AAAA,IACf;AAEA,QAAI,mBAAmB,MAAM;AAAA,IAE7B;AAEA,QAAI,QAAQ,iBAAiB;AAC3B,aAAO,YAAY,QAAQ;AAC3B,YAAM,CAAC,SAAS,OAAO,IAAI,QAAQ,gBAAgB,MAAM;AACzD,yBAAmB;AACnB,cAAQ,KAAK,MAAM;AACjB,eAAO,YAAY,QAAQ;AAC3B,gBAAQ,2BAA2B,MAAM;AAAA,MAC3C,CAAC;AAAA,IACH;AAEA,UAAM,UAAU,MAAM;AACpB,aAAO,QAAQ;AACf,uBAAiB;AAAA,IACnB;AAEA,QAAI,IAAI,WAAW;AACjB,UAAI,UAAU,OAAO;AAAA,IACvB,OAAO;AACL,YAAM,kBAAkB,IAAI;AAC5B,UAAI,UAAU,SAAS,kBAAkB;AACvC,gBAAQ;AACR,wBAAgB;AAAA,MAClB;AAAA,IACF;AAEA,QAAI,wBAAQ;AACV,UAAI,MAAM;AAAA,QACR,eAAe;AAEb,cAAI,CAAC,KAAK,WAAW;AACnB,kBAAM,eAAe,CAAC;AACtB,mBAAO,eAAe,MAAM,aAAa;AAAA,cACvC,KAAK,MAAM;AAAA,cACX,KAAK,CAAC,MAAM,OAAO,OAAO,cAAc,CAAC;AAAA,YAC3C,CAAC;AAAA,UACH;AAEA,eAAK,UAAU,SAAS,IAAI;AAE5B,cAAI,QAAQ,IAAI,aAAa,eAAe;AAC1C,gBAAI,SAAS,KAAK,SAAS,QAAQ,wBAAwB;AACzD,iDAAc,MAAM,MAAM;AAAA,YAC5B;AAAA,UACF;AAAA,QACF;AAAA,MACF,CAAC;AAAA,IACH,OAAO;AACL,UAAI,QAAQ,WAAW,MAAM;AAE7B,UAAI,QAAQ,IAAI,aAAa,eAAe;AAC1C,YAAI,QAAQ,wBAAwB;AAClC,6CAAc,KAAK,MAAM;AAAA,QAC3B;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Q as QueryClient } from './queryClient-
|
|
2
|
-
import { QueryClientConfig } from '
|
|
1
|
+
import { Q as QueryClient } from './queryClient-DjQXZR5U.cjs';
|
|
2
|
+
import { QueryClientConfig } from './types.cjs';
|
|
3
|
+
import '@tanstack/query-core';
|
|
3
4
|
import 'vue-demi';
|
|
4
|
-
import './types.cjs';
|
|
5
5
|
|
|
6
6
|
type ClientPersister = (client: QueryClient) => [() => void, Promise<void>];
|
|
7
7
|
interface CommonOptions {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Q as QueryClient } from './queryClient-
|
|
2
|
-
import { QueryClientConfig } from '
|
|
1
|
+
import { Q as QueryClient } from './queryClient-DKRxpPKC.js';
|
|
2
|
+
import { QueryClientConfig } from './types.js';
|
|
3
|
+
import '@tanstack/query-core';
|
|
3
4
|
import 'vue-demi';
|
|
4
|
-
import './types.js';
|
|
5
5
|
|
|
6
6
|
type ClientPersister = (client: QueryClient) => [() => void, Promise<void>];
|
|
7
7
|
interface CommonOptions {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/vueQueryPlugin.ts"],"sourcesContent":["import { isVue2 } from 'vue-demi'\nimport { isServer } from '@tanstack/query-core'\n\nimport { QueryClient } from './queryClient'\nimport { getClientKey } from './utils'\nimport { setupDevtools } from './devtools/devtools'\nimport type { QueryClientConfig } from '
|
|
1
|
+
{"version":3,"sources":["../../src/vueQueryPlugin.ts"],"sourcesContent":["import { isVue2 } from 'vue-demi'\nimport { isServer } from '@tanstack/query-core'\n\nimport { QueryClient } from './queryClient'\nimport { getClientKey } from './utils'\nimport { setupDevtools } from './devtools/devtools'\nimport type { QueryClientConfig } from './types'\n\ntype ClientPersister = (client: QueryClient) => [() => void, Promise<void>]\n\ninterface CommonOptions {\n enableDevtoolsV6Plugin?: boolean\n queryClientKey?: string\n clientPersister?: ClientPersister\n clientPersisterOnSuccess?: (client: QueryClient) => void\n}\n\ninterface ConfigOptions extends CommonOptions {\n queryClientConfig?: QueryClientConfig\n}\n\ninterface ClientOptions extends CommonOptions {\n queryClient?: QueryClient\n}\n\nexport type VueQueryPluginOptions = ConfigOptions | ClientOptions\n\nexport const VueQueryPlugin = {\n install: (app: any, options: VueQueryPluginOptions = {}) => {\n const clientKey = getClientKey(options.queryClientKey)\n let client: QueryClient\n\n if ('queryClient' in options && options.queryClient) {\n client = options.queryClient\n } else {\n const clientConfig =\n 'queryClientConfig' in options ? options.queryClientConfig : undefined\n client = new QueryClient(clientConfig)\n }\n\n if (!isServer) {\n client.mount()\n }\n\n let persisterUnmount = () => {\n // noop\n }\n\n if (options.clientPersister) {\n client.isRestoring.value = true\n const [unmount, promise] = options.clientPersister(client)\n persisterUnmount = unmount\n promise.then(() => {\n client.isRestoring.value = false\n options.clientPersisterOnSuccess?.(client)\n })\n }\n\n const cleanup = () => {\n client.unmount()\n persisterUnmount()\n }\n\n if (app.onUnmount) {\n app.onUnmount(cleanup)\n } else {\n const originalUnmount = app.unmount\n app.unmount = function vueQueryUnmount() {\n cleanup()\n originalUnmount()\n }\n }\n\n if (isVue2) {\n app.mixin({\n beforeCreate() {\n // HACK: taken from provide(): https://github.com/vuejs/composition-api/blob/master/src/apis/inject.ts#L30\n if (!this._provided) {\n const provideCache = {}\n Object.defineProperty(this, '_provided', {\n get: () => provideCache,\n set: (v) => Object.assign(provideCache, v),\n })\n }\n\n this._provided[clientKey] = client\n\n if (process.env.NODE_ENV === 'development') {\n if (this === this.$root && options.enableDevtoolsV6Plugin) {\n setupDevtools(this, client)\n }\n }\n },\n })\n } else {\n app.provide(clientKey, client)\n\n if (process.env.NODE_ENV === 'development') {\n if (options.enableDevtoolsV6Plugin) {\n setupDevtools(app, client)\n }\n }\n }\n },\n}\n"],"mappings":";AAAA,SAAS,cAAc;AACvB,SAAS,gBAAgB;AAEzB,SAAS,mBAAmB;AAC5B,SAAS,oBAAoB;AAC7B,SAAS,qBAAqB;AAsBvB,IAAM,iBAAiB;AAAA,EAC5B,SAAS,CAAC,KAAU,UAAiC,CAAC,MAAM;AAC1D,UAAM,YAAY,aAAa,QAAQ,cAAc;AACrD,QAAI;AAEJ,QAAI,iBAAiB,WAAW,QAAQ,aAAa;AACnD,eAAS,QAAQ;AAAA,IACnB,OAAO;AACL,YAAM,eACJ,uBAAuB,UAAU,QAAQ,oBAAoB;AAC/D,eAAS,IAAI,YAAY,YAAY;AAAA,IACvC;AAEA,QAAI,CAAC,UAAU;AACb,aAAO,MAAM;AAAA,IACf;AAEA,QAAI,mBAAmB,MAAM;AAAA,IAE7B;AAEA,QAAI,QAAQ,iBAAiB;AAC3B,aAAO,YAAY,QAAQ;AAC3B,YAAM,CAAC,SAAS,OAAO,IAAI,QAAQ,gBAAgB,MAAM;AACzD,yBAAmB;AACnB,cAAQ,KAAK,MAAM;AACjB,eAAO,YAAY,QAAQ;AAC3B,gBAAQ,2BAA2B,MAAM;AAAA,MAC3C,CAAC;AAAA,IACH;AAEA,UAAM,UAAU,MAAM;AACpB,aAAO,QAAQ;AACf,uBAAiB;AAAA,IACnB;AAEA,QAAI,IAAI,WAAW;AACjB,UAAI,UAAU,OAAO;AAAA,IACvB,OAAO;AACL,YAAM,kBAAkB,IAAI;AAC5B,UAAI,UAAU,SAAS,kBAAkB;AACvC,gBAAQ;AACR,wBAAgB;AAAA,MAClB;AAAA,IACF;AAEA,QAAI,QAAQ;AACV,UAAI,MAAM;AAAA,QACR,eAAe;AAEb,cAAI,CAAC,KAAK,WAAW;AACnB,kBAAM,eAAe,CAAC;AACtB,mBAAO,eAAe,MAAM,aAAa;AAAA,cACvC,KAAK,MAAM;AAAA,cACX,KAAK,CAAC,MAAM,OAAO,OAAO,cAAc,CAAC;AAAA,YAC3C,CAAC;AAAA,UACH;AAEA,eAAK,UAAU,SAAS,IAAI;AAE5B,cAAI,QAAQ,IAAI,aAAa,eAAe;AAC1C,gBAAI,SAAS,KAAK,SAAS,QAAQ,wBAAwB;AACzD,4BAAc,MAAM,MAAM;AAAA,YAC5B;AAAA,UACF;AAAA,QACF;AAAA,MACF,CAAC;AAAA,IACH,OAAO;AACL,UAAI,QAAQ,WAAW,MAAM;AAE7B,UAAI,QAAQ,IAAI,aAAa,eAAe;AAC1C,YAAI,QAAQ,wBAAwB;AAClC,wBAAc,KAAK,MAAM;AAAA,QAC3B;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
|
package/package.json
CHANGED
package/src/queryClient.ts
CHANGED
|
@@ -3,6 +3,9 @@ import { QueryClient as QC } from '@tanstack/query-core'
|
|
|
3
3
|
import { cloneDeepUnref } from './utils'
|
|
4
4
|
import { QueryCache } from './queryCache'
|
|
5
5
|
import { MutationCache } from './mutationCache'
|
|
6
|
+
import type { UseQueryOptions } from './useQuery'
|
|
7
|
+
import type { Ref } from 'vue-demi'
|
|
8
|
+
import type { MaybeRefDeep, NoUnknown, QueryClientConfig } from './types'
|
|
6
9
|
import type {
|
|
7
10
|
CancelOptions,
|
|
8
11
|
DefaultError,
|
|
@@ -20,7 +23,6 @@ import type {
|
|
|
20
23
|
MutationObserverOptions,
|
|
21
24
|
NoInfer,
|
|
22
25
|
OmitKeyof,
|
|
23
|
-
QueryClientConfig,
|
|
24
26
|
QueryFilters,
|
|
25
27
|
QueryKey,
|
|
26
28
|
QueryObserverOptions,
|
|
@@ -31,9 +33,6 @@ import type {
|
|
|
31
33
|
SetDataOptions,
|
|
32
34
|
Updater,
|
|
33
35
|
} from '@tanstack/query-core'
|
|
34
|
-
import type { UseQueryOptions } from './useQuery'
|
|
35
|
-
import type { Ref } from 'vue-demi'
|
|
36
|
-
import type { MaybeRefDeep, NoUnknown } from './types'
|
|
37
36
|
|
|
38
37
|
export class QueryClient extends QC {
|
|
39
38
|
constructor(config: QueryClientConfig = {}) {
|
package/src/types.ts
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
DefaultError,
|
|
3
|
+
DehydrateOptions,
|
|
4
|
+
HydrateOptions,
|
|
5
|
+
MutationCache,
|
|
6
|
+
MutationObserverOptions,
|
|
7
|
+
OmitKeyof,
|
|
8
|
+
QueryCache,
|
|
9
|
+
QueryObserverOptions,
|
|
10
|
+
} from '@tanstack/query-core'
|
|
1
11
|
import type { ComputedRef, Ref, UnwrapRef } from 'vue-demi'
|
|
2
12
|
|
|
3
13
|
type Primitive = string | number | boolean | bigint | symbol | undefined | null
|
|
@@ -48,3 +58,29 @@ export type DeepUnwrapRef<T> = T extends UnwrapLeaf
|
|
|
48
58
|
export type DistributiveOmit<T, TKeyOfAny extends keyof any> = T extends any
|
|
49
59
|
? Omit<T, TKeyOfAny>
|
|
50
60
|
: never
|
|
61
|
+
|
|
62
|
+
export interface DefaultOptions<TError = DefaultError> {
|
|
63
|
+
queries?: OmitKeyof<
|
|
64
|
+
QueryObserverOptions<unknown, TError>,
|
|
65
|
+
'queryKey' | 'queryFn'
|
|
66
|
+
> & {
|
|
67
|
+
/**
|
|
68
|
+
* Return data in a shallow ref object (it is `false` by default). It can be set to `true` to return data in a shallow ref object, which can improve performance if your data does not need to be deeply reactive.
|
|
69
|
+
*/
|
|
70
|
+
shallow?: boolean
|
|
71
|
+
}
|
|
72
|
+
mutations?: MutationObserverOptions<unknown, TError, unknown, unknown> & {
|
|
73
|
+
/**
|
|
74
|
+
* Return data in a shallow ref object (it is `false` by default). It can be set to `true` to return data in a shallow ref object, which can improve performance if your data does not need to be deeply reactive.
|
|
75
|
+
*/
|
|
76
|
+
shallow?: boolean
|
|
77
|
+
}
|
|
78
|
+
hydrate?: HydrateOptions['defaultOptions']
|
|
79
|
+
dehydrate?: DehydrateOptions
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export interface QueryClientConfig {
|
|
83
|
+
queryCache?: QueryCache
|
|
84
|
+
mutationCache?: MutationCache
|
|
85
|
+
defaultOptions?: DefaultOptions
|
|
86
|
+
}
|
package/src/useInfiniteQuery.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { InfiniteQueryObserver } from '@tanstack/query-core'
|
|
2
2
|
import { useBaseQuery } from './useBaseQuery'
|
|
3
|
+
import type {
|
|
4
|
+
DefinedInitialDataInfiniteOptions,
|
|
5
|
+
UndefinedInitialDataInfiniteOptions,
|
|
6
|
+
} from './infiniteQueryOptions'
|
|
3
7
|
import type {
|
|
4
8
|
DefaultError,
|
|
5
9
|
InfiniteData,
|
|
@@ -11,7 +15,12 @@ import type {
|
|
|
11
15
|
|
|
12
16
|
import type { UseBaseQueryReturnType } from './useBaseQuery'
|
|
13
17
|
|
|
14
|
-
import type {
|
|
18
|
+
import type {
|
|
19
|
+
DeepUnwrapRef,
|
|
20
|
+
MaybeRef,
|
|
21
|
+
MaybeRefDeep,
|
|
22
|
+
MaybeRefOrGetter,
|
|
23
|
+
} from './types'
|
|
15
24
|
import type { QueryClient } from './queryClient'
|
|
16
25
|
|
|
17
26
|
export type UseInfiniteQueryOptions<
|
|
@@ -21,37 +30,39 @@ export type UseInfiniteQueryOptions<
|
|
|
21
30
|
TQueryData = TQueryFnData,
|
|
22
31
|
TQueryKey extends QueryKey = QueryKey,
|
|
23
32
|
TPageParam = unknown,
|
|
24
|
-
> =
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
33
|
+
> = MaybeRef<
|
|
34
|
+
{
|
|
35
|
+
[Property in keyof InfiniteQueryObserverOptions<
|
|
36
|
+
TQueryFnData,
|
|
37
|
+
TError,
|
|
38
|
+
TData,
|
|
39
|
+
TQueryData,
|
|
40
|
+
TQueryKey,
|
|
41
|
+
TPageParam
|
|
42
|
+
>]: Property extends 'enabled'
|
|
43
|
+
? MaybeRefOrGetter<
|
|
44
|
+
InfiniteQueryObserverOptions<
|
|
45
|
+
TQueryFnData,
|
|
46
|
+
TError,
|
|
47
|
+
TData,
|
|
48
|
+
TQueryData,
|
|
49
|
+
DeepUnwrapRef<TQueryKey>
|
|
50
|
+
>[Property]
|
|
51
|
+
>
|
|
52
|
+
: MaybeRefDeep<
|
|
53
|
+
InfiniteQueryObserverOptions<
|
|
54
|
+
TQueryFnData,
|
|
55
|
+
TError,
|
|
56
|
+
TData,
|
|
57
|
+
TQueryData,
|
|
58
|
+
DeepUnwrapRef<TQueryKey>,
|
|
59
|
+
TPageParam
|
|
60
|
+
>[Property]
|
|
61
|
+
>
|
|
62
|
+
} & {
|
|
63
|
+
shallow?: boolean
|
|
64
|
+
}
|
|
65
|
+
>
|
|
55
66
|
|
|
56
67
|
export type UseInfiniteQueryReturnType<TData, TError> = UseBaseQueryReturnType<
|
|
57
68
|
TData,
|
|
@@ -59,6 +70,40 @@ export type UseInfiniteQueryReturnType<TData, TError> = UseBaseQueryReturnType<
|
|
|
59
70
|
InfiniteQueryObserverResult<TData, TError>
|
|
60
71
|
>
|
|
61
72
|
|
|
73
|
+
export function useInfiniteQuery<
|
|
74
|
+
TQueryFnData,
|
|
75
|
+
TError = DefaultError,
|
|
76
|
+
TData = InfiniteData<TQueryFnData>,
|
|
77
|
+
TQueryKey extends QueryKey = QueryKey,
|
|
78
|
+
TPageParam = unknown,
|
|
79
|
+
>(
|
|
80
|
+
options: DefinedInitialDataInfiniteOptions<
|
|
81
|
+
TQueryFnData,
|
|
82
|
+
TError,
|
|
83
|
+
TData,
|
|
84
|
+
TQueryKey,
|
|
85
|
+
TPageParam
|
|
86
|
+
>,
|
|
87
|
+
queryClient?: QueryClient,
|
|
88
|
+
): UseInfiniteQueryReturnType<TData, TError>
|
|
89
|
+
|
|
90
|
+
export function useInfiniteQuery<
|
|
91
|
+
TQueryFnData,
|
|
92
|
+
TError = DefaultError,
|
|
93
|
+
TData = InfiniteData<TQueryFnData>,
|
|
94
|
+
TQueryKey extends QueryKey = QueryKey,
|
|
95
|
+
TPageParam = unknown,
|
|
96
|
+
>(
|
|
97
|
+
options: UndefinedInitialDataInfiniteOptions<
|
|
98
|
+
TQueryFnData,
|
|
99
|
+
TError,
|
|
100
|
+
TData,
|
|
101
|
+
TQueryKey,
|
|
102
|
+
TPageParam
|
|
103
|
+
>,
|
|
104
|
+
queryClient?: QueryClient,
|
|
105
|
+
): UseInfiniteQueryReturnType<TData, TError>
|
|
106
|
+
|
|
62
107
|
export function useInfiniteQuery<
|
|
63
108
|
TQueryFnData,
|
|
64
109
|
TError = DefaultError,
|
|
@@ -75,10 +120,16 @@ export function useInfiniteQuery<
|
|
|
75
120
|
TPageParam
|
|
76
121
|
>,
|
|
77
122
|
queryClient?: QueryClient,
|
|
78
|
-
): UseInfiniteQueryReturnType<TData, TError>
|
|
123
|
+
): UseInfiniteQueryReturnType<TData, TError>
|
|
124
|
+
|
|
125
|
+
export function useInfiniteQuery(
|
|
126
|
+
options: UseInfiniteQueryOptions,
|
|
127
|
+
queryClient?: QueryClient,
|
|
128
|
+
) {
|
|
79
129
|
return useBaseQuery(
|
|
130
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
|
|
80
131
|
InfiniteQueryObserver as typeof QueryObserver,
|
|
81
132
|
options,
|
|
82
133
|
queryClient,
|
|
83
|
-
)
|
|
134
|
+
)
|
|
84
135
|
}
|
package/src/useMutation.ts
CHANGED
|
@@ -29,6 +29,9 @@ type MutationResult<TData, TError, TVariables, TContext> = DistributiveOmit<
|
|
|
29
29
|
|
|
30
30
|
type UseMutationOptionsBase<TData, TError, TVariables, TContext> =
|
|
31
31
|
MutationObserverOptions<TData, TError, TVariables, TContext> & {
|
|
32
|
+
/**
|
|
33
|
+
* Return data in a shallow ref object (it is `false` by default). It can be set to `true` to return data in a shallow ref object, which can improve performance if your data does not need to be deeply reactive.
|
|
34
|
+
*/
|
|
32
35
|
shallow?: boolean
|
|
33
36
|
}
|
|
34
37
|
|
package/src/useQuery.ts
CHANGED
|
@@ -51,6 +51,9 @@ export type UseQueryOptions<
|
|
|
51
51
|
>[Property]
|
|
52
52
|
>
|
|
53
53
|
} & {
|
|
54
|
+
/**
|
|
55
|
+
* Return data in a shallow ref object (it is `false` by default). It can be set to `true` to return data in a shallow ref object, which can improve performance if your data does not need to be deeply reactive.
|
|
56
|
+
*/
|
|
54
57
|
shallow?: boolean
|
|
55
58
|
}
|
|
56
59
|
>
|
package/src/vueQueryPlugin.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { isServer } from '@tanstack/query-core'
|
|
|
4
4
|
import { QueryClient } from './queryClient'
|
|
5
5
|
import { getClientKey } from './utils'
|
|
6
6
|
import { setupDevtools } from './devtools/devtools'
|
|
7
|
-
import type { QueryClientConfig } from '
|
|
7
|
+
import type { QueryClientConfig } from './types'
|
|
8
8
|
|
|
9
9
|
type ClientPersister = (client: QueryClient) => [() => void, Promise<void>]
|
|
10
10
|
|