@tanstack/vue-query 5.101.4 → 5.102.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/README.md +17 -0
- package/build/legacy/devtools/devtools.cjs +203 -258
- package/build/legacy/devtools/devtools.cjs.map +1 -1
- package/build/legacy/devtools/devtools.d.cts +6 -1
- package/build/legacy/devtools/devtools.d.cts.map +1 -0
- package/build/legacy/devtools/devtools.d.ts +6 -1
- package/build/legacy/devtools/devtools.d.ts.map +1 -0
- package/build/legacy/devtools/devtools.js +200 -236
- package/build/legacy/devtools/devtools.js.map +1 -1
- package/build/legacy/devtools/utils.cjs +37 -94
- package/build/legacy/devtools/utils.cjs.map +1 -1
- package/build/legacy/devtools/utils.d.cts +18 -5
- package/build/legacy/devtools/utils.d.cts.map +1 -0
- package/build/legacy/devtools/utils.d.ts +18 -5
- package/build/legacy/devtools/utils.d.ts.map +1 -0
- package/build/legacy/devtools/utils.js +32 -65
- package/build/legacy/devtools/utils.js.map +1 -1
- package/build/legacy/index.cjs +44 -83
- package/build/legacy/index.d.cts +17 -173
- package/build/legacy/index.d.ts +17 -173
- package/build/legacy/index.js +6 -27
- package/build/legacy/infiniteQueryOptions.cjs +6 -30
- package/build/legacy/infiniteQueryOptions.cjs.map +1 -1
- package/build/legacy/infiniteQueryOptions.d.cts +2 -3
- package/build/legacy/infiniteQueryOptions.d.ts +2 -3
- package/build/legacy/infiniteQueryOptions.js +5 -5
- package/build/legacy/infiniteQueryOptions.js.map +1 -1
- package/build/legacy/mutationCache.cjs +13 -37
- package/build/legacy/mutationCache.cjs.map +1 -1
- package/build/legacy/mutationCache.d.cts +10 -1
- package/build/legacy/mutationCache.d.cts.map +1 -0
- package/build/legacy/mutationCache.d.ts +10 -1
- package/build/legacy/mutationCache.d.ts.map +1 -0
- package/build/legacy/mutationCache.js +12 -12
- package/build/legacy/mutationCache.js.map +1 -1
- package/build/legacy/mutationOptions.cjs +6 -30
- package/build/legacy/mutationOptions.cjs.map +1 -1
- package/build/legacy/mutationOptions.d.cts +10 -1
- package/build/legacy/mutationOptions.d.cts.map +1 -0
- package/build/legacy/mutationOptions.d.ts +10 -1
- package/build/legacy/mutationOptions.d.ts.map +1 -0
- package/build/legacy/mutationOptions.js +5 -5
- package/build/legacy/mutationOptions.js.map +1 -1
- package/build/legacy/queryCache.cjs +13 -37
- package/build/legacy/queryCache.cjs.map +1 -1
- package/build/legacy/queryCache.d.cts +10 -1
- package/build/legacy/queryCache.d.cts.map +1 -0
- package/build/legacy/queryCache.d.ts +10 -1
- package/build/legacy/queryCache.d.ts.map +1 -0
- package/build/legacy/queryCache.js +12 -12
- package/build/legacy/queryCache.js.map +1 -1
- package/build/legacy/queryClient-C07d0chJ.d.cts +97 -0
- package/build/legacy/queryClient-C07d0chJ.d.cts.map +1 -0
- package/build/legacy/queryClient-hf6i_vCa.d.ts +97 -0
- package/build/legacy/queryClient-hf6i_vCa.d.ts.map +1 -0
- package/build/legacy/queryClient.cjs +104 -142
- package/build/legacy/queryClient.cjs.map +1 -1
- package/build/legacy/queryClient.d.cts +2 -1
- package/build/legacy/queryClient.d.ts +2 -1
- package/build/legacy/queryClient.js +103 -117
- package/build/legacy/queryClient.js.map +1 -1
- package/build/legacy/queryOptions.cjs +6 -30
- package/build/legacy/queryOptions.cjs.map +1 -1
- package/build/legacy/queryOptions.d.cts +19 -4
- package/build/legacy/queryOptions.d.cts.map +1 -0
- package/build/legacy/queryOptions.d.ts +19 -4
- package/build/legacy/queryOptions.d.ts.map +1 -0
- package/build/legacy/queryOptions.js +5 -5
- package/build/legacy/queryOptions.js.map +1 -1
- package/build/legacy/types-BzZi3_rS.d.cts +33 -0
- package/build/legacy/types-BzZi3_rS.d.cts.map +1 -0
- package/build/legacy/types-BzZi3_rS.d.ts +33 -0
- package/build/legacy/types-BzZi3_rS.d.ts.map +1 -0
- package/build/legacy/types.cjs +0 -19
- package/build/legacy/types.d.cts +2 -11
- package/build/legacy/types.d.ts +2 -11
- package/build/legacy/types.js +1 -1
- package/build/legacy/useBaseQuery.cjs +78 -140
- package/build/legacy/useBaseQuery.cjs.map +1 -1
- package/build/legacy/useBaseQuery.d.cts +2 -2
- package/build/legacy/useBaseQuery.d.ts +2 -2
- package/build/legacy/useBaseQuery.js +76 -124
- package/build/legacy/useBaseQuery.js.map +1 -1
- package/build/legacy/useInfiniteQuery.cjs +8 -36
- package/build/legacy/useInfiniteQuery.cjs.map +1 -1
- package/build/legacy/useInfiniteQuery.d.cts +2 -3
- package/build/legacy/useInfiniteQuery.d.ts +2 -3
- package/build/legacy/useInfiniteQuery.js +6 -10
- package/build/legacy/useInfiniteQuery.js.map +1 -1
- package/build/legacy/useIsFetching.cjs +23 -51
- package/build/legacy/useIsFetching.cjs.map +1 -1
- package/build/legacy/useIsFetching.d.cts +10 -2
- package/build/legacy/useIsFetching.d.cts.map +1 -0
- package/build/legacy/useIsFetching.d.ts +10 -2
- package/build/legacy/useIsFetching.d.ts.map +1 -0
- package/build/legacy/useIsFetching.js +21 -25
- package/build/legacy/useIsFetching.js.map +1 -1
- package/build/legacy/useMutation.cjs +42 -76
- package/build/legacy/useMutation.cjs.map +1 -1
- package/build/legacy/useMutation.d.cts +17 -3
- package/build/legacy/useMutation.d.cts.map +1 -0
- package/build/legacy/useMutation.d.ts +17 -3
- package/build/legacy/useMutation.d.ts.map +1 -0
- package/build/legacy/useMutation.js +39 -59
- package/build/legacy/useMutation.js.map +1 -1
- package/build/legacy/useMutationState.cjs +38 -75
- package/build/legacy/useMutationState.cjs.map +1 -1
- package/build/legacy/useMutationState.d.cts +16 -4
- package/build/legacy/useMutationState.d.cts.map +1 -0
- package/build/legacy/useMutationState.d.ts +16 -4
- package/build/legacy/useMutationState.d.ts.map +1 -0
- package/build/legacy/useMutationState.js +35 -55
- package/build/legacy/useMutationState.js.map +1 -1
- package/build/legacy/usePrefetchInfiniteQuery.cjs +19 -50
- package/build/legacy/usePrefetchInfiniteQuery.cjs.map +1 -1
- package/build/legacy/usePrefetchInfiniteQuery.d.cts +11 -2
- package/build/legacy/usePrefetchInfiniteQuery.d.cts.map +1 -0
- package/build/legacy/usePrefetchInfiniteQuery.d.ts +11 -2
- package/build/legacy/usePrefetchInfiniteQuery.d.ts.map +1 -0
- package/build/legacy/usePrefetchInfiniteQuery.js +17 -24
- package/build/legacy/usePrefetchInfiniteQuery.js.map +1 -1
- package/build/legacy/usePrefetchQuery.cjs +19 -48
- package/build/legacy/usePrefetchQuery.cjs.map +1 -1
- package/build/legacy/usePrefetchQuery.d.cts +11 -2
- package/build/legacy/usePrefetchQuery.d.cts.map +1 -0
- package/build/legacy/usePrefetchQuery.d.ts +11 -2
- package/build/legacy/usePrefetchQuery.d.ts.map +1 -0
- package/build/legacy/usePrefetchQuery.js +17 -22
- package/build/legacy/usePrefetchQuery.js.map +1 -1
- package/build/legacy/useQueries.cjs +57 -113
- package/build/legacy/useQueries.cjs.map +1 -1
- package/build/legacy/useQueries.d.cts +63 -3
- package/build/legacy/useQueries.d.cts.map +1 -0
- package/build/legacy/useQueries.d.ts +63 -3
- package/build/legacy/useQueries.d.ts.map +1 -0
- package/build/legacy/useQueries.js +55 -96
- package/build/legacy/useQueries.js.map +1 -1
- package/build/legacy/useQuery.cjs +8 -32
- package/build/legacy/useQuery.cjs.map +1 -1
- package/build/legacy/useQuery.d.cts +2 -6
- package/build/legacy/useQuery.d.ts +2 -6
- package/build/legacy/useQuery.js +6 -6
- package/build/legacy/useQuery.js.map +1 -1
- package/build/legacy/useQueryClient.cjs +12 -44
- package/build/legacy/useQueryClient.cjs.map +1 -1
- package/build/legacy/useQueryClient.d.cts +6 -1
- package/build/legacy/useQueryClient.d.cts.map +1 -0
- package/build/legacy/useQueryClient.d.ts +6 -1
- package/build/legacy/useQueryClient.d.ts.map +1 -0
- package/build/legacy/useQueryClient.js +10 -18
- package/build/legacy/useQueryClient.js.map +1 -1
- package/build/legacy/utils.cjs +40 -89
- package/build/legacy/utils.cjs.map +1 -1
- package/build/legacy/utils.d.cts +11 -6
- package/build/legacy/utils.d.cts.map +1 -0
- package/build/legacy/utils.d.ts +11 -6
- package/build/legacy/utils.d.ts.map +1 -0
- package/build/legacy/utils.js +32 -57
- package/build/legacy/utils.js.map +1 -1
- package/build/legacy/vueQueryPlugin.cjs +61 -103
- package/build/legacy/vueQueryPlugin.cjs.map +1 -1
- package/build/legacy/vueQueryPlugin.d.cts +23 -2
- package/build/legacy/vueQueryPlugin.d.cts.map +1 -0
- package/build/legacy/vueQueryPlugin.d.ts +23 -2
- package/build/legacy/vueQueryPlugin.d.ts.map +1 -0
- package/build/legacy/vueQueryPlugin.js +59 -77
- package/build/legacy/vueQueryPlugin.js.map +1 -1
- package/build/modern/devtools/devtools.cjs +201 -256
- package/build/modern/devtools/devtools.cjs.map +1 -1
- package/build/modern/devtools/devtools.d.cts +6 -1
- package/build/modern/devtools/devtools.d.cts.map +1 -0
- package/build/modern/devtools/devtools.d.ts +6 -1
- package/build/modern/devtools/devtools.d.ts.map +1 -0
- package/build/modern/devtools/devtools.js +198 -234
- package/build/modern/devtools/devtools.js.map +1 -1
- package/build/modern/devtools/utils.cjs +37 -94
- package/build/modern/devtools/utils.cjs.map +1 -1
- package/build/modern/devtools/utils.d.cts +18 -5
- package/build/modern/devtools/utils.d.cts.map +1 -0
- package/build/modern/devtools/utils.d.ts +18 -5
- package/build/modern/devtools/utils.d.ts.map +1 -0
- package/build/modern/devtools/utils.js +32 -65
- package/build/modern/devtools/utils.js.map +1 -1
- package/build/modern/index.cjs +44 -83
- package/build/modern/index.d.cts +17 -173
- package/build/modern/index.d.ts +17 -173
- package/build/modern/index.js +6 -27
- package/build/modern/infiniteQueryOptions.cjs +6 -30
- package/build/modern/infiniteQueryOptions.cjs.map +1 -1
- package/build/modern/infiniteQueryOptions.d.cts +2 -3
- package/build/modern/infiniteQueryOptions.d.ts +2 -3
- package/build/modern/infiniteQueryOptions.js +5 -5
- package/build/modern/infiniteQueryOptions.js.map +1 -1
- package/build/modern/mutationCache.cjs +13 -37
- package/build/modern/mutationCache.cjs.map +1 -1
- package/build/modern/mutationCache.d.cts +10 -1
- package/build/modern/mutationCache.d.cts.map +1 -0
- package/build/modern/mutationCache.d.ts +10 -1
- package/build/modern/mutationCache.d.ts.map +1 -0
- package/build/modern/mutationCache.js +12 -12
- package/build/modern/mutationCache.js.map +1 -1
- package/build/modern/mutationOptions.cjs +6 -30
- package/build/modern/mutationOptions.cjs.map +1 -1
- package/build/modern/mutationOptions.d.cts +10 -1
- package/build/modern/mutationOptions.d.cts.map +1 -0
- package/build/modern/mutationOptions.d.ts +10 -1
- package/build/modern/mutationOptions.d.ts.map +1 -0
- package/build/modern/mutationOptions.js +5 -5
- package/build/modern/mutationOptions.js.map +1 -1
- package/build/modern/queryCache.cjs +13 -37
- package/build/modern/queryCache.cjs.map +1 -1
- package/build/modern/queryCache.d.cts +10 -1
- package/build/modern/queryCache.d.cts.map +1 -0
- package/build/modern/queryCache.d.ts +10 -1
- package/build/modern/queryCache.d.ts.map +1 -0
- package/build/modern/queryCache.js +12 -12
- package/build/modern/queryCache.js.map +1 -1
- package/build/modern/queryClient-C07d0chJ.d.cts +97 -0
- package/build/modern/queryClient-C07d0chJ.d.cts.map +1 -0
- package/build/modern/queryClient-hf6i_vCa.d.ts +97 -0
- package/build/modern/queryClient-hf6i_vCa.d.ts.map +1 -0
- package/build/modern/queryClient.cjs +104 -142
- package/build/modern/queryClient.cjs.map +1 -1
- package/build/modern/queryClient.d.cts +2 -1
- package/build/modern/queryClient.d.ts +2 -1
- package/build/modern/queryClient.js +103 -117
- package/build/modern/queryClient.js.map +1 -1
- package/build/modern/queryOptions.cjs +6 -30
- package/build/modern/queryOptions.cjs.map +1 -1
- package/build/modern/queryOptions.d.cts +19 -4
- package/build/modern/queryOptions.d.cts.map +1 -0
- package/build/modern/queryOptions.d.ts +19 -4
- package/build/modern/queryOptions.d.ts.map +1 -0
- package/build/modern/queryOptions.js +5 -5
- package/build/modern/queryOptions.js.map +1 -1
- package/build/modern/types-BzZi3_rS.d.cts +33 -0
- package/build/modern/types-BzZi3_rS.d.cts.map +1 -0
- package/build/modern/types-BzZi3_rS.d.ts +33 -0
- package/build/modern/types-BzZi3_rS.d.ts.map +1 -0
- package/build/modern/types.cjs +0 -19
- package/build/modern/types.d.cts +2 -11
- package/build/modern/types.d.ts +2 -11
- package/build/modern/types.js +1 -1
- package/build/modern/useBaseQuery.cjs +77 -139
- package/build/modern/useBaseQuery.cjs.map +1 -1
- package/build/modern/useBaseQuery.d.cts +2 -2
- package/build/modern/useBaseQuery.d.ts +2 -2
- package/build/modern/useBaseQuery.js +75 -123
- package/build/modern/useBaseQuery.js.map +1 -1
- package/build/modern/useInfiniteQuery.cjs +8 -36
- package/build/modern/useInfiniteQuery.cjs.map +1 -1
- package/build/modern/useInfiniteQuery.d.cts +2 -3
- package/build/modern/useInfiniteQuery.d.ts +2 -3
- package/build/modern/useInfiniteQuery.js +6 -10
- package/build/modern/useInfiniteQuery.js.map +1 -1
- package/build/modern/useIsFetching.cjs +23 -51
- package/build/modern/useIsFetching.cjs.map +1 -1
- package/build/modern/useIsFetching.d.cts +10 -2
- package/build/modern/useIsFetching.d.cts.map +1 -0
- package/build/modern/useIsFetching.d.ts +10 -2
- package/build/modern/useIsFetching.d.ts.map +1 -0
- package/build/modern/useIsFetching.js +21 -25
- package/build/modern/useIsFetching.js.map +1 -1
- package/build/modern/useMutation.cjs +42 -76
- package/build/modern/useMutation.cjs.map +1 -1
- package/build/modern/useMutation.d.cts +17 -3
- package/build/modern/useMutation.d.cts.map +1 -0
- package/build/modern/useMutation.d.ts +17 -3
- package/build/modern/useMutation.d.ts.map +1 -0
- package/build/modern/useMutation.js +39 -59
- package/build/modern/useMutation.js.map +1 -1
- package/build/modern/useMutationState.cjs +38 -75
- package/build/modern/useMutationState.cjs.map +1 -1
- package/build/modern/useMutationState.d.cts +16 -4
- package/build/modern/useMutationState.d.cts.map +1 -0
- package/build/modern/useMutationState.d.ts +16 -4
- package/build/modern/useMutationState.d.ts.map +1 -0
- package/build/modern/useMutationState.js +35 -55
- package/build/modern/useMutationState.js.map +1 -1
- package/build/modern/usePrefetchInfiniteQuery.cjs +19 -50
- package/build/modern/usePrefetchInfiniteQuery.cjs.map +1 -1
- package/build/modern/usePrefetchInfiniteQuery.d.cts +11 -2
- package/build/modern/usePrefetchInfiniteQuery.d.cts.map +1 -0
- package/build/modern/usePrefetchInfiniteQuery.d.ts +11 -2
- package/build/modern/usePrefetchInfiniteQuery.d.ts.map +1 -0
- package/build/modern/usePrefetchInfiniteQuery.js +17 -24
- package/build/modern/usePrefetchInfiniteQuery.js.map +1 -1
- package/build/modern/usePrefetchQuery.cjs +19 -48
- package/build/modern/usePrefetchQuery.cjs.map +1 -1
- package/build/modern/usePrefetchQuery.d.cts +11 -2
- package/build/modern/usePrefetchQuery.d.cts.map +1 -0
- package/build/modern/usePrefetchQuery.d.ts +11 -2
- package/build/modern/usePrefetchQuery.d.ts.map +1 -0
- package/build/modern/usePrefetchQuery.js +17 -22
- package/build/modern/usePrefetchQuery.js.map +1 -1
- package/build/modern/useQueries.cjs +56 -112
- package/build/modern/useQueries.cjs.map +1 -1
- package/build/modern/useQueries.d.cts +63 -3
- package/build/modern/useQueries.d.cts.map +1 -0
- package/build/modern/useQueries.d.ts +63 -3
- package/build/modern/useQueries.d.ts.map +1 -0
- package/build/modern/useQueries.js +54 -95
- package/build/modern/useQueries.js.map +1 -1
- package/build/modern/useQuery.cjs +8 -32
- package/build/modern/useQuery.cjs.map +1 -1
- package/build/modern/useQuery.d.cts +2 -6
- package/build/modern/useQuery.d.ts +2 -6
- package/build/modern/useQuery.js +6 -6
- package/build/modern/useQuery.js.map +1 -1
- package/build/modern/useQueryClient.cjs +12 -44
- package/build/modern/useQueryClient.cjs.map +1 -1
- package/build/modern/useQueryClient.d.cts +6 -1
- package/build/modern/useQueryClient.d.cts.map +1 -0
- package/build/modern/useQueryClient.d.ts +6 -1
- package/build/modern/useQueryClient.d.ts.map +1 -0
- package/build/modern/useQueryClient.js +10 -18
- package/build/modern/useQueryClient.js.map +1 -1
- package/build/modern/utils.cjs +40 -89
- package/build/modern/utils.cjs.map +1 -1
- package/build/modern/utils.d.cts +11 -6
- package/build/modern/utils.d.cts.map +1 -0
- package/build/modern/utils.d.ts +11 -6
- package/build/modern/utils.d.ts.map +1 -0
- package/build/modern/utils.js +32 -57
- package/build/modern/utils.js.map +1 -1
- package/build/modern/vueQueryPlugin.cjs +60 -102
- package/build/modern/vueQueryPlugin.cjs.map +1 -1
- package/build/modern/vueQueryPlugin.d.cts +23 -2
- package/build/modern/vueQueryPlugin.d.cts.map +1 -0
- package/build/modern/vueQueryPlugin.d.ts +23 -2
- package/build/modern/vueQueryPlugin.d.ts.map +1 -0
- package/build/modern/vueQueryPlugin.js +58 -76
- package/build/modern/vueQueryPlugin.js.map +1 -1
- package/package.json +5 -7
- package/src/index.ts +5 -1
- package/src/infiniteQueryOptions.ts +5 -7
- package/src/queryClient.ts +150 -36
- package/src/queryOptions.ts +32 -14
- package/src/useMutation.ts +4 -4
- package/src/useMutationState.ts +33 -8
- package/src/usePrefetchInfiniteQuery.ts +22 -42
- package/src/usePrefetchQuery.ts +29 -5
- package/src/useQuery.ts +19 -9
- package/build/legacy/_tsup-dts-rollup.d.cts +0 -884
- package/build/legacy/_tsup-dts-rollup.d.ts +0 -884
- package/build/legacy/index.cjs.map +0 -1
- package/build/legacy/index.js.map +0 -1
- package/build/legacy/types.cjs.map +0 -1
- package/build/legacy/types.js.map +0 -1
- package/build/modern/_tsup-dts-rollup.d.cts +0 -884
- package/build/modern/_tsup-dts-rollup.d.ts +0 -884
- package/build/modern/index.cjs.map +0 -1
- package/build/modern/index.js.map +0 -1
- package/build/modern/types.cjs.map +0 -1
- package/build/modern/types.js.map +0 -1
|
@@ -1,79 +1,61 @@
|
|
|
1
|
-
// src/vueQueryPlugin.ts
|
|
2
|
-
import { isVue2 } from "vue-demi";
|
|
3
|
-
import { environmentManager } from "@tanstack/query-core";
|
|
4
|
-
import { QueryClient } from "./queryClient.js";
|
|
5
1
|
import { getClientKey } from "./utils.js";
|
|
2
|
+
import { QueryClient as QueryClient$1 } from "./queryClient.js";
|
|
6
3
|
import { setupDevtools } from "./devtools/devtools.js";
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
} else {
|
|
67
|
-
app.provide(clientKey, client);
|
|
68
|
-
if (process.env.NODE_ENV === "development") {
|
|
69
|
-
if (options.enableDevtoolsV6Plugin) {
|
|
70
|
-
setupDevtools(app, client);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
export {
|
|
77
|
-
VueQueryPlugin
|
|
78
|
-
};
|
|
4
|
+
import { environmentManager } from "@tanstack/query-core";
|
|
5
|
+
import { isVue2 } from "vue-demi";
|
|
6
|
+
//#region src/vueQueryPlugin.ts
|
|
7
|
+
const VueQueryPlugin = { install: (app, options = {}) => {
|
|
8
|
+
const clientKey = getClientKey(options.queryClientKey);
|
|
9
|
+
let client;
|
|
10
|
+
if ("queryClient" in options && options.queryClient) client = options.queryClient;
|
|
11
|
+
else {
|
|
12
|
+
const clientConfig = "queryClientConfig" in options ? options.queryClientConfig : void 0;
|
|
13
|
+
client = new QueryClient$1(clientConfig);
|
|
14
|
+
}
|
|
15
|
+
if (!environmentManager.isServer()) client.mount();
|
|
16
|
+
let persisterUnmount = () => {};
|
|
17
|
+
if (options.clientPersister) {
|
|
18
|
+
if (client.isRestoring) client.isRestoring.value = true;
|
|
19
|
+
const [unmount, promise] = options.clientPersister(client);
|
|
20
|
+
persisterUnmount = unmount;
|
|
21
|
+
promise.then(() => {
|
|
22
|
+
if (client.isRestoring) client.isRestoring.value = false;
|
|
23
|
+
options.clientPersisterOnSuccess?.(client);
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
const cleanup = () => {
|
|
27
|
+
client.unmount();
|
|
28
|
+
persisterUnmount();
|
|
29
|
+
};
|
|
30
|
+
if (app.onUnmount) app.onUnmount(cleanup);
|
|
31
|
+
else {
|
|
32
|
+
const originalUnmount = app.unmount;
|
|
33
|
+
app.unmount = function vueQueryUnmount() {
|
|
34
|
+
cleanup();
|
|
35
|
+
originalUnmount();
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
if (isVue2) app.mixin({ beforeCreate() {
|
|
39
|
+
if (!this._provided) {
|
|
40
|
+
const provideCache = {};
|
|
41
|
+
Object.defineProperty(this, "_provided", {
|
|
42
|
+
get: () => provideCache,
|
|
43
|
+
set: (v) => Object.assign(provideCache, v)
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
this._provided[clientKey] = client;
|
|
47
|
+
if (process.env.NODE_ENV === "development") {
|
|
48
|
+
if (this === this.$root && options.enableDevtoolsV6Plugin) setupDevtools(this, client);
|
|
49
|
+
}
|
|
50
|
+
} });
|
|
51
|
+
else {
|
|
52
|
+
app.provide(clientKey, client);
|
|
53
|
+
if (process.env.NODE_ENV === "development") {
|
|
54
|
+
if (options.enableDevtoolsV6Plugin) setupDevtools(app, client);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
} };
|
|
58
|
+
//#endregion
|
|
59
|
+
export { VueQueryPlugin };
|
|
60
|
+
|
|
79
61
|
//# sourceMappingURL=vueQueryPlugin.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/vueQueryPlugin.ts"],"sourcesContent":["import { isVue2 } from 'vue-demi'\nimport { environmentManager } 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 (!environmentManager.isServer()) {\n client.mount()\n }\n\n let persisterUnmount = () => {\n // noop\n }\n\n if (options.clientPersister) {\n if (client.isRestoring) {\n client.isRestoring.value = true\n }\n const [unmount, promise] = options.clientPersister(client)\n persisterUnmount = unmount\n promise.then(() => {\n if (client.isRestoring) {\n client.isRestoring.value = false\n }\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":"
|
|
1
|
+
{"version":3,"file":"vueQueryPlugin.js","names":["QueryClient"],"sources":["../../src/vueQueryPlugin.ts"],"sourcesContent":["import { isVue2 } from 'vue-demi'\nimport { environmentManager } 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 (!environmentManager.isServer()) {\n client.mount()\n }\n\n let persisterUnmount = () => {\n // noop\n }\n\n if (options.clientPersister) {\n if (client.isRestoring) {\n client.isRestoring.value = true\n }\n const [unmount, promise] = options.clientPersister(client)\n persisterUnmount = unmount\n promise.then(() => {\n if (client.isRestoring) {\n client.isRestoring.value = false\n }\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":";;;;;;AA2BA,MAAa,iBAAiB,EAC5B,UAAU,KAAU,UAAiC,CAAC,MAAM;CAC1D,MAAM,YAAY,aAAa,QAAQ,cAAc;CACrD,IAAI;CAEJ,IAAI,iBAAiB,WAAW,QAAQ,aACtC,SAAS,QAAQ;MACZ;EACL,MAAM,eACJ,uBAAuB,UAAU,QAAQ,oBAAoB,KAAA;EAC/D,SAAS,IAAIA,cAAY,YAAY;CACvC;CAEA,IAAI,CAAC,mBAAmB,SAAS,GAC/B,OAAO,MAAM;CAGf,IAAI,yBAAyB,CAE7B;CAEA,IAAI,QAAQ,iBAAiB;EAC3B,IAAI,OAAO,aACT,OAAO,YAAY,QAAQ;EAE7B,MAAM,CAAC,SAAS,WAAW,QAAQ,gBAAgB,MAAM;EACzD,mBAAmB;EACnB,QAAQ,WAAW;GACjB,IAAI,OAAO,aACT,OAAO,YAAY,QAAQ;GAE7B,QAAQ,2BAA2B,MAAM;EAC3C,CAAC;CACH;CAEA,MAAM,gBAAgB;EACpB,OAAO,QAAQ;EACf,iBAAiB;CACnB;CAEA,IAAI,IAAI,WACN,IAAI,UAAU,OAAO;MAChB;EACL,MAAM,kBAAkB,IAAI;EAC5B,IAAI,UAAU,SAAS,kBAAkB;GACvC,QAAQ;GACR,gBAAgB;EAClB;CACF;CAEA,IAAI,QACF,IAAI,MAAM,EACR,eAAe;EAEb,IAAI,CAAC,KAAK,WAAW;GACnB,MAAM,eAAe,CAAC;GACtB,OAAO,eAAe,MAAM,aAAa;IACvC,WAAW;IACX,MAAM,MAAM,OAAO,OAAO,cAAc,CAAC;GAC3C,CAAC;EACH;EAEA,KAAK,UAAU,aAAa;EAE5B,IAAI,QAAQ,IAAI,aAAa,eACvB;OAAA,SAAS,KAAK,SAAS,QAAQ,wBACjC,cAAc,MAAM,MAAM;EAAA;CAGhC,EACF,CAAC;MACI;EACL,IAAI,QAAQ,WAAW,MAAM;EAE7B,IAAI,QAAQ,IAAI,aAAa,eACvB;OAAA,QAAQ,wBACV,cAAc,KAAK,MAAM;EAAA;CAG/B;AACF,EACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/vue-query",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.102.0",
|
|
4
4
|
"description": "Hooks for managing, caching and syncing asynchronous and remote data in Vue",
|
|
5
5
|
"author": "Damian Osipiuk",
|
|
6
6
|
"license": "MIT",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"@tanstack/match-sorter-utils": "^8.19.4",
|
|
43
43
|
"@vue/devtools-api": "^6.6.3",
|
|
44
44
|
"vue-demi": "^0.14.10",
|
|
45
|
-
"@tanstack/query-core": "5.
|
|
45
|
+
"@tanstack/query-core": "5.102.0"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@vitejs/plugin-vue": "^5.2.4",
|
|
@@ -64,23 +64,21 @@
|
|
|
64
64
|
},
|
|
65
65
|
"scripts": {
|
|
66
66
|
"clean": "premove ./build ./coverage ./dist-ts",
|
|
67
|
-
"compile": "tsc --build",
|
|
67
|
+
"compile": "node ../../node_modules/typescript/lib/tsc.js --build",
|
|
68
68
|
"test:eslint": "eslint --concurrency=auto ./src",
|
|
69
69
|
"test:types": "vue-demi-switch 3 && pnpm run \"/^test:types:ts[0-9]{2}$/\"",
|
|
70
|
-
"test:types:ts54": "node ../../node_modules/typescript54/lib/tsc.js --build tsconfig.legacy.json",
|
|
71
|
-
"test:types:ts55": "node ../../node_modules/typescript55/lib/tsc.js --build tsconfig.legacy.json",
|
|
72
70
|
"test:types:ts56": "node ../../node_modules/typescript56/lib/tsc.js --build tsconfig.legacy.json",
|
|
73
71
|
"test:types:ts57": "node ../../node_modules/typescript57/lib/tsc.js --build tsconfig.legacy.json",
|
|
74
72
|
"test:types:ts58": "node ../../node_modules/typescript58/lib/tsc.js --build tsconfig.legacy.json",
|
|
75
73
|
"test:types:ts59": "node ../../node_modules/typescript59/lib/tsc.js --build tsconfig.legacy.json",
|
|
76
74
|
"test:types:tscurrent": "tsc --build",
|
|
77
|
-
"test:types:
|
|
75
|
+
"test:types:ts70": "node ../../node_modules/typescript70/lib/tsc.js --build tsconfig.legacy.json",
|
|
78
76
|
"test:lib": "pnpm run test:lib:2 && pnpm run test:lib:2.7 && pnpm run test:lib:3",
|
|
79
77
|
"test:lib:2": "vue-demi-switch 2 vue2 && vitest",
|
|
80
78
|
"test:lib:2.7": "vue-demi-switch 2.7 vue2.7 && vitest",
|
|
81
79
|
"test:lib:3": "vue-demi-switch 3 && vitest",
|
|
82
80
|
"test:lib:dev": "pnpm run test:lib --watch",
|
|
83
81
|
"test:build": "publint --strict && attw --pack",
|
|
84
|
-
"build": "
|
|
82
|
+
"build": "tsdown --tsconfig tsconfig.prod.json"
|
|
85
83
|
}
|
|
86
84
|
}
|
package/src/index.ts
CHANGED
|
@@ -6,7 +6,11 @@ export { VueQueryPlugin } from './vueQueryPlugin'
|
|
|
6
6
|
export { QueryClient } from './queryClient'
|
|
7
7
|
export { QueryCache } from './queryCache'
|
|
8
8
|
export { queryOptions } from './queryOptions'
|
|
9
|
-
export
|
|
9
|
+
export type {
|
|
10
|
+
QueryOptions,
|
|
11
|
+
UndefinedInitialQueryOptionsWithDataTag,
|
|
12
|
+
DefinedInitialQueryOptionsWithDataTag,
|
|
13
|
+
} from './queryOptions'
|
|
10
14
|
export { infiniteQueryOptions } from './infiniteQueryOptions'
|
|
11
15
|
export type {
|
|
12
16
|
DefinedInitialDataInfiniteOptions,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type {
|
|
2
|
-
DataTag,
|
|
3
2
|
DefaultError,
|
|
4
3
|
InfiniteData,
|
|
5
4
|
NonUndefinedGuard,
|
|
6
5
|
QueryKey,
|
|
6
|
+
QueryKeyWithDataTag,
|
|
7
7
|
} from '@tanstack/query-core'
|
|
8
8
|
import type { UseInfiniteQueryOptions } from './useInfiniteQuery'
|
|
9
9
|
|
|
@@ -61,9 +61,8 @@ export function infiniteQueryOptions<
|
|
|
61
61
|
TData,
|
|
62
62
|
TQueryKey,
|
|
63
63
|
TPageParam
|
|
64
|
-
> &
|
|
65
|
-
|
|
66
|
-
}
|
|
64
|
+
> &
|
|
65
|
+
QueryKeyWithDataTag<TQueryKey, InfiniteData<TQueryFnData>, TError>
|
|
67
66
|
|
|
68
67
|
export function infiniteQueryOptions<
|
|
69
68
|
TQueryFnData,
|
|
@@ -85,9 +84,8 @@ export function infiniteQueryOptions<
|
|
|
85
84
|
TData,
|
|
86
85
|
TQueryKey,
|
|
87
86
|
TPageParam
|
|
88
|
-
> &
|
|
89
|
-
|
|
90
|
-
}
|
|
87
|
+
> &
|
|
88
|
+
QueryKeyWithDataTag<TQueryKey, InfiniteData<TQueryFnData>, TError>
|
|
91
89
|
|
|
92
90
|
export function infiniteQueryOptions(options: unknown) {
|
|
93
91
|
return options
|
package/src/queryClient.ts
CHANGED
|
@@ -14,14 +14,15 @@ import type {
|
|
|
14
14
|
FetchInfiniteQueryOptions,
|
|
15
15
|
FetchQueryOptions,
|
|
16
16
|
InferDataFromTag,
|
|
17
|
-
InferErrorFromTag,
|
|
18
17
|
InfiniteData,
|
|
18
|
+
InfiniteQueryExecuteOptions,
|
|
19
19
|
InvalidateOptions,
|
|
20
20
|
InvalidateQueryFilters,
|
|
21
21
|
MutationFilters,
|
|
22
22
|
MutationKey,
|
|
23
23
|
MutationObserverOptions,
|
|
24
24
|
OmitKeyof,
|
|
25
|
+
QueryExecuteOptions,
|
|
25
26
|
QueryFilters,
|
|
26
27
|
QueryKey,
|
|
27
28
|
QueryObserverOptions,
|
|
@@ -65,6 +66,9 @@ export class QueryClient extends QC {
|
|
|
65
66
|
return super.getQueryData(cloneDeepUnref(queryKey))
|
|
66
67
|
}
|
|
67
68
|
|
|
69
|
+
/**
|
|
70
|
+
* @deprecated Use queryClient.query({ ...options, staleTime: 'static' }) instead. This method will be removed in the next major version.
|
|
71
|
+
*/
|
|
68
72
|
ensureQueryData<
|
|
69
73
|
TQueryFnData,
|
|
70
74
|
TError = DefaultError,
|
|
@@ -149,24 +153,14 @@ export class QueryClient extends QC {
|
|
|
149
153
|
return super.getQueryState(cloneDeepUnref(queryKey))
|
|
150
154
|
}
|
|
151
155
|
|
|
152
|
-
removeQueries<
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
TTaggedQueryKey extends QueryKey = QueryKey,
|
|
156
|
-
TInferredQueryFnData = InferDataFromTag<TQueryFnData, TTaggedQueryKey>,
|
|
157
|
-
TInferredError = InferErrorFromTag<TError, TTaggedQueryKey>,
|
|
158
|
-
>(filters?: QueryFilters<TTaggedQueryKey>): void
|
|
156
|
+
removeQueries<TTaggedQueryKey extends QueryKey = QueryKey>(
|
|
157
|
+
filters?: QueryFilters<TTaggedQueryKey>,
|
|
158
|
+
): void
|
|
159
159
|
removeQueries(filters: MaybeRefDeep<QueryFilters> = {}): void {
|
|
160
160
|
return super.removeQueries(cloneDeepUnref(filters))
|
|
161
161
|
}
|
|
162
162
|
|
|
163
|
-
resetQueries<
|
|
164
|
-
TQueryFnData = unknown,
|
|
165
|
-
TError = DefaultError,
|
|
166
|
-
TTaggedQueryKey extends QueryKey = QueryKey,
|
|
167
|
-
TInferredQueryFnData = InferDataFromTag<TQueryFnData, TTaggedQueryKey>,
|
|
168
|
-
TInferredError = InferErrorFromTag<TError, TTaggedQueryKey>,
|
|
169
|
-
>(
|
|
163
|
+
resetQueries<TTaggedQueryKey extends QueryKey = QueryKey>(
|
|
170
164
|
filters?: QueryFilters<TTaggedQueryKey>,
|
|
171
165
|
options?: MaybeRefDeep<ResetOptions>,
|
|
172
166
|
): Promise<void>
|
|
@@ -177,13 +171,7 @@ export class QueryClient extends QC {
|
|
|
177
171
|
return super.resetQueries(cloneDeepUnref(filters), cloneDeepUnref(options))
|
|
178
172
|
}
|
|
179
173
|
|
|
180
|
-
cancelQueries<
|
|
181
|
-
TQueryFnData = unknown,
|
|
182
|
-
TError = DefaultError,
|
|
183
|
-
TTaggedQueryKey extends QueryKey = QueryKey,
|
|
184
|
-
TInferredQueryFnData = InferDataFromTag<TQueryFnData, TTaggedQueryKey>,
|
|
185
|
-
TInferredError = InferErrorFromTag<TError, TTaggedQueryKey>,
|
|
186
|
-
>(
|
|
174
|
+
cancelQueries<TTaggedQueryKey extends QueryKey = QueryKey>(
|
|
187
175
|
filters?: QueryFilters<TTaggedQueryKey>,
|
|
188
176
|
options?: MaybeRefDeep<CancelOptions>,
|
|
189
177
|
): Promise<void>
|
|
@@ -194,13 +182,7 @@ export class QueryClient extends QC {
|
|
|
194
182
|
return super.cancelQueries(cloneDeepUnref(filters), cloneDeepUnref(options))
|
|
195
183
|
}
|
|
196
184
|
|
|
197
|
-
invalidateQueries<
|
|
198
|
-
TQueryFnData = unknown,
|
|
199
|
-
TError = DefaultError,
|
|
200
|
-
TTaggedQueryKey extends QueryKey = QueryKey,
|
|
201
|
-
TInferredQueryFnData = InferDataFromTag<TQueryFnData, TTaggedQueryKey>,
|
|
202
|
-
TInferredError = InferErrorFromTag<TError, TTaggedQueryKey>,
|
|
203
|
-
>(
|
|
185
|
+
invalidateQueries<TTaggedQueryKey extends QueryKey = QueryKey>(
|
|
204
186
|
filters?:
|
|
205
187
|
| InvalidateQueryFilters<TTaggedQueryKey>
|
|
206
188
|
| (() => InvalidateQueryFilters<TTaggedQueryKey>),
|
|
@@ -240,13 +222,7 @@ export class QueryClient extends QC {
|
|
|
240
222
|
})
|
|
241
223
|
}
|
|
242
224
|
|
|
243
|
-
refetchQueries<
|
|
244
|
-
TQueryFnData = unknown,
|
|
245
|
-
TError = DefaultError,
|
|
246
|
-
TTaggedQueryKey extends QueryKey = QueryKey,
|
|
247
|
-
TInferredQueryFnData = InferDataFromTag<TQueryFnData, TTaggedQueryKey>,
|
|
248
|
-
TInferredError = InferErrorFromTag<TError, TTaggedQueryKey>,
|
|
249
|
-
>(
|
|
225
|
+
refetchQueries<TTaggedQueryKey extends QueryKey = QueryKey>(
|
|
250
226
|
filters?: RefetchQueryFilters<TTaggedQueryKey>,
|
|
251
227
|
options?: MaybeRefDeep<RefetchOptions>,
|
|
252
228
|
): Promise<void>
|
|
@@ -260,6 +236,69 @@ export class QueryClient extends QC {
|
|
|
260
236
|
)
|
|
261
237
|
}
|
|
262
238
|
|
|
239
|
+
// These one-shot imperative methods do not resolve top-level option getters.
|
|
240
|
+
// Resolve getters explicitly before calling, e.g. queryClient.query(options()).
|
|
241
|
+
query<
|
|
242
|
+
TQueryFnData,
|
|
243
|
+
TError = DefaultError,
|
|
244
|
+
TData = TQueryFnData,
|
|
245
|
+
TQueryData = TQueryFnData,
|
|
246
|
+
TQueryKey extends QueryKey = QueryKey,
|
|
247
|
+
TPageParam = never,
|
|
248
|
+
>(
|
|
249
|
+
options: QueryExecuteOptions<
|
|
250
|
+
TQueryFnData,
|
|
251
|
+
TError,
|
|
252
|
+
TData,
|
|
253
|
+
TQueryData,
|
|
254
|
+
TQueryKey,
|
|
255
|
+
TPageParam
|
|
256
|
+
>,
|
|
257
|
+
): Promise<TData>
|
|
258
|
+
query<
|
|
259
|
+
TQueryFnData,
|
|
260
|
+
TError = DefaultError,
|
|
261
|
+
TData = TQueryFnData,
|
|
262
|
+
TQueryData = TQueryFnData,
|
|
263
|
+
TQueryKey extends QueryKey = QueryKey,
|
|
264
|
+
TPageParam = never,
|
|
265
|
+
>(
|
|
266
|
+
options: MaybeRefDeep<
|
|
267
|
+
QueryExecuteOptions<
|
|
268
|
+
TQueryFnData,
|
|
269
|
+
TError,
|
|
270
|
+
TData,
|
|
271
|
+
TQueryData,
|
|
272
|
+
TQueryKey,
|
|
273
|
+
TPageParam
|
|
274
|
+
>
|
|
275
|
+
>,
|
|
276
|
+
): Promise<TData>
|
|
277
|
+
query<
|
|
278
|
+
TQueryFnData,
|
|
279
|
+
TError = DefaultError,
|
|
280
|
+
TData = TQueryFnData,
|
|
281
|
+
TQueryData = TQueryFnData,
|
|
282
|
+
TQueryKey extends QueryKey = QueryKey,
|
|
283
|
+
TPageParam = never,
|
|
284
|
+
>(
|
|
285
|
+
options: MaybeRefDeep<
|
|
286
|
+
QueryExecuteOptions<
|
|
287
|
+
TQueryFnData,
|
|
288
|
+
TError,
|
|
289
|
+
TData,
|
|
290
|
+
TQueryData,
|
|
291
|
+
TQueryKey,
|
|
292
|
+
TPageParam
|
|
293
|
+
>
|
|
294
|
+
>,
|
|
295
|
+
): Promise<TData> {
|
|
296
|
+
return super.query(cloneDeepUnref(options))
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
/**
|
|
300
|
+
* @deprecated Use queryClient.query(options) instead. This method will be removed in the next major version.
|
|
301
|
+
*/
|
|
263
302
|
fetchQuery<
|
|
264
303
|
TQueryFnData,
|
|
265
304
|
TError = DefaultError,
|
|
@@ -308,6 +347,9 @@ export class QueryClient extends QC {
|
|
|
308
347
|
return super.fetchQuery(cloneDeepUnref(options))
|
|
309
348
|
}
|
|
310
349
|
|
|
350
|
+
/**
|
|
351
|
+
* @deprecated Use queryClient.query(options) instead. You can swallow errors with `.catch(noop)`. This method will be removed in the next major version.
|
|
352
|
+
*/
|
|
311
353
|
prefetchQuery<
|
|
312
354
|
TQueryFnData = unknown,
|
|
313
355
|
TError = DefaultError,
|
|
@@ -339,6 +381,75 @@ export class QueryClient extends QC {
|
|
|
339
381
|
return super.prefetchQuery(cloneDeepUnref(options))
|
|
340
382
|
}
|
|
341
383
|
|
|
384
|
+
// These one-shot imperative methods do not resolve top-level option getters.
|
|
385
|
+
// Resolve getters explicitly before calling, e.g. queryClient.infiniteQuery(options()).
|
|
386
|
+
infiniteQuery<
|
|
387
|
+
TQueryFnData = unknown,
|
|
388
|
+
TError = DefaultError,
|
|
389
|
+
TData = InfiniteData<TQueryFnData>,
|
|
390
|
+
TQueryKey extends QueryKey = QueryKey,
|
|
391
|
+
TPageParam = unknown,
|
|
392
|
+
>(
|
|
393
|
+
options: InfiniteQueryExecuteOptions<
|
|
394
|
+
TQueryFnData,
|
|
395
|
+
TError,
|
|
396
|
+
TData,
|
|
397
|
+
TQueryKey,
|
|
398
|
+
TPageParam
|
|
399
|
+
>,
|
|
400
|
+
): Promise<
|
|
401
|
+
Array<TData> extends Array<InfiniteData<TQueryFnData>>
|
|
402
|
+
? InfiniteData<TQueryFnData, TPageParam>
|
|
403
|
+
: TData
|
|
404
|
+
>
|
|
405
|
+
infiniteQuery<
|
|
406
|
+
TQueryFnData = unknown,
|
|
407
|
+
TError = DefaultError,
|
|
408
|
+
TData = InfiniteData<TQueryFnData>,
|
|
409
|
+
TQueryKey extends QueryKey = QueryKey,
|
|
410
|
+
TPageParam = unknown,
|
|
411
|
+
>(
|
|
412
|
+
options: MaybeRefDeep<
|
|
413
|
+
InfiniteQueryExecuteOptions<
|
|
414
|
+
TQueryFnData,
|
|
415
|
+
TError,
|
|
416
|
+
TData,
|
|
417
|
+
TQueryKey,
|
|
418
|
+
TPageParam
|
|
419
|
+
>
|
|
420
|
+
>,
|
|
421
|
+
): Promise<
|
|
422
|
+
Array<TData> extends Array<InfiniteData<TQueryFnData>>
|
|
423
|
+
? InfiniteData<TQueryFnData, TPageParam>
|
|
424
|
+
: TData
|
|
425
|
+
>
|
|
426
|
+
infiniteQuery<
|
|
427
|
+
TQueryFnData = unknown,
|
|
428
|
+
TError = DefaultError,
|
|
429
|
+
TData = InfiniteData<TQueryFnData>,
|
|
430
|
+
TQueryKey extends QueryKey = QueryKey,
|
|
431
|
+
TPageParam = unknown,
|
|
432
|
+
>(
|
|
433
|
+
options: MaybeRefDeep<
|
|
434
|
+
InfiniteQueryExecuteOptions<
|
|
435
|
+
TQueryFnData,
|
|
436
|
+
TError,
|
|
437
|
+
TData,
|
|
438
|
+
TQueryKey,
|
|
439
|
+
TPageParam
|
|
440
|
+
>
|
|
441
|
+
>,
|
|
442
|
+
): Promise<
|
|
443
|
+
Array<TData> extends Array<InfiniteData<TQueryFnData>>
|
|
444
|
+
? InfiniteData<TQueryFnData, TPageParam>
|
|
445
|
+
: TData
|
|
446
|
+
> {
|
|
447
|
+
return super.infiniteQuery(cloneDeepUnref(options))
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
/**
|
|
451
|
+
* @deprecated Use queryClient.infiniteQuery(options) instead. This method will be removed in the next major version.
|
|
452
|
+
*/
|
|
342
453
|
fetchInfiniteQuery<
|
|
343
454
|
TQueryFnData = unknown,
|
|
344
455
|
TError = DefaultError,
|
|
@@ -391,6 +502,9 @@ export class QueryClient extends QC {
|
|
|
391
502
|
return super.fetchInfiniteQuery(cloneDeepUnref(options))
|
|
392
503
|
}
|
|
393
504
|
|
|
505
|
+
/**
|
|
506
|
+
* @deprecated use void queryClient.infiniteQuery(options) instead. You can swallow errors with `.catch(noop)`. This method will be removed in the next major version.
|
|
507
|
+
*/
|
|
394
508
|
prefetchInfiniteQuery<
|
|
395
509
|
TQueryFnData,
|
|
396
510
|
TError = DefaultError,
|
package/src/queryOptions.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { DeepUnwrapRef, MaybeRefOrGetter, ShallowOption } from './types'
|
|
2
2
|
import type {
|
|
3
|
-
DataTag,
|
|
4
3
|
DefaultError,
|
|
5
4
|
InitialDataFunction,
|
|
6
5
|
NonUndefinedGuard,
|
|
7
6
|
QueryBooleanOption,
|
|
8
7
|
QueryKey,
|
|
8
|
+
QueryKeyWithDataTag,
|
|
9
9
|
QueryObserverOptions,
|
|
10
10
|
} from '@tanstack/query-core'
|
|
11
11
|
|
|
@@ -65,6 +65,22 @@ export type DefinedInitialQueryOptions<
|
|
|
65
65
|
| (() => NonUndefinedGuard<TQueryFnData>)
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
+
export type UndefinedInitialQueryOptionsWithDataTag<
|
|
69
|
+
TQueryFnData = unknown,
|
|
70
|
+
TError = DefaultError,
|
|
71
|
+
TData = TQueryFnData,
|
|
72
|
+
TQueryKey extends QueryKey = QueryKey,
|
|
73
|
+
> = UndefinedInitialQueryOptions<TQueryFnData, TError, TData, TQueryKey> &
|
|
74
|
+
QueryKeyWithDataTag<TQueryKey, TQueryFnData, TError>
|
|
75
|
+
|
|
76
|
+
export type DefinedInitialQueryOptionsWithDataTag<
|
|
77
|
+
TQueryFnData = unknown,
|
|
78
|
+
TError = DefaultError,
|
|
79
|
+
TData = TQueryFnData,
|
|
80
|
+
TQueryKey extends QueryKey = QueryKey,
|
|
81
|
+
> = DefinedInitialQueryOptions<TQueryFnData, TError, TData, TQueryKey> &
|
|
82
|
+
QueryKeyWithDataTag<TQueryKey, TQueryFnData, TError>
|
|
83
|
+
|
|
68
84
|
export function queryOptions<
|
|
69
85
|
TQueryFnData = unknown,
|
|
70
86
|
TError = DefaultError,
|
|
@@ -72,9 +88,7 @@ export function queryOptions<
|
|
|
72
88
|
TQueryKey extends QueryKey = QueryKey,
|
|
73
89
|
>(
|
|
74
90
|
options: DefinedInitialQueryOptions<TQueryFnData, TError, TData, TQueryKey>,
|
|
75
|
-
):
|
|
76
|
-
queryKey: DataTag<TQueryKey, TQueryFnData, TError>
|
|
77
|
-
}
|
|
91
|
+
): DefinedInitialQueryOptionsWithDataTag<TQueryFnData, TError, TData, TQueryKey>
|
|
78
92
|
|
|
79
93
|
export function queryOptions<
|
|
80
94
|
TQueryFnData = unknown,
|
|
@@ -88,9 +102,12 @@ export function queryOptions<
|
|
|
88
102
|
TData,
|
|
89
103
|
TQueryKey
|
|
90
104
|
>,
|
|
91
|
-
): () =>
|
|
92
|
-
|
|
93
|
-
|
|
105
|
+
): () => DefinedInitialQueryOptionsWithDataTag<
|
|
106
|
+
TQueryFnData,
|
|
107
|
+
TError,
|
|
108
|
+
TData,
|
|
109
|
+
TQueryKey
|
|
110
|
+
>
|
|
94
111
|
|
|
95
112
|
export function queryOptions<
|
|
96
113
|
TQueryFnData = unknown,
|
|
@@ -99,9 +116,12 @@ export function queryOptions<
|
|
|
99
116
|
TQueryKey extends QueryKey = QueryKey,
|
|
100
117
|
>(
|
|
101
118
|
options: UndefinedInitialQueryOptions<TQueryFnData, TError, TData, TQueryKey>,
|
|
102
|
-
):
|
|
103
|
-
|
|
104
|
-
|
|
119
|
+
): UndefinedInitialQueryOptionsWithDataTag<
|
|
120
|
+
TQueryFnData,
|
|
121
|
+
TError,
|
|
122
|
+
TData,
|
|
123
|
+
TQueryKey
|
|
124
|
+
>
|
|
105
125
|
|
|
106
126
|
export function queryOptions<
|
|
107
127
|
TQueryFnData = unknown,
|
|
@@ -115,14 +135,12 @@ export function queryOptions<
|
|
|
115
135
|
TData,
|
|
116
136
|
TQueryKey
|
|
117
137
|
>,
|
|
118
|
-
): () =>
|
|
138
|
+
): () => UndefinedInitialQueryOptionsWithDataTag<
|
|
119
139
|
TQueryFnData,
|
|
120
140
|
TError,
|
|
121
141
|
TData,
|
|
122
142
|
TQueryKey
|
|
123
|
-
>
|
|
124
|
-
queryKey: DataTag<TQueryKey, TQueryFnData, TError>
|
|
125
|
-
}
|
|
143
|
+
>
|
|
126
144
|
|
|
127
145
|
export function queryOptions(options: unknown) {
|
|
128
146
|
return options
|
package/src/useMutation.ts
CHANGED
|
@@ -17,7 +17,6 @@ import type {
|
|
|
17
17
|
DefaultError,
|
|
18
18
|
DistributiveOmit,
|
|
19
19
|
MutateFunction,
|
|
20
|
-
MutateOptions,
|
|
21
20
|
MutationObserverResult,
|
|
22
21
|
} from '@tanstack/query-core'
|
|
23
22
|
import type { MaybeRefDeep, MutationOptions } from './types'
|
|
@@ -108,10 +107,11 @@ export function useMutation<
|
|
|
108
107
|
})
|
|
109
108
|
|
|
110
109
|
const mutate = (
|
|
111
|
-
|
|
112
|
-
|
|
110
|
+
...args: Parameters<
|
|
111
|
+
MutateFunction<TData, TError, TVariables, TOnMutateResult>
|
|
112
|
+
>
|
|
113
113
|
) => {
|
|
114
|
-
observer.mutate(
|
|
114
|
+
observer.mutate(args[0] as TVariables, args[1]).catch(() => {
|
|
115
115
|
// This is intentional
|
|
116
116
|
})
|
|
117
117
|
}
|