react-query-kit 3.1.1 → 3.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +50 -10
- package/build/lib/types.d.ts +6 -6
- package/build/stats-html.html +1 -1
- package/build/stats.json +95 -95
- package/package.json +1 -1
- package/src/types.ts +6 -6
package/README.md
CHANGED
|
@@ -48,6 +48,7 @@ English | [简体中文](./README-zh_CN.md)
|
|
|
48
48
|
- [createMutation](#createmutation)
|
|
49
49
|
- [router](#router)
|
|
50
50
|
- [Middleware](#middleware)
|
|
51
|
+
- [TypeScript](#typescript)
|
|
51
52
|
- [Type inference](#type-inference)
|
|
52
53
|
- [FAQ](#faq)
|
|
53
54
|
- [Migration](#migration)
|
|
@@ -86,12 +87,12 @@ If you still on React Query Kit v2? Check out the v2 docs here: https://github.c
|
|
|
86
87
|
import { QueryClient, dehydrate } from '@tanstack/react-query'
|
|
87
88
|
import { createQuery } from 'react-query-kit'
|
|
88
89
|
|
|
89
|
-
type
|
|
90
|
+
type Data = { title: string; content: string }
|
|
90
91
|
type Variables = { id: number }
|
|
91
92
|
|
|
92
93
|
const usePost = createQuery({
|
|
93
94
|
queryKey: ['posts'],
|
|
94
|
-
fetcher: (variables: Variables): Promise<
|
|
95
|
+
fetcher: (variables: Variables): Promise<Data> => {
|
|
95
96
|
return fetch(`/posts/${variables.id}`).then(res => res.json())
|
|
96
97
|
},
|
|
97
98
|
// u can also pass middleware to cutomize this hook's behavior
|
|
@@ -142,7 +143,7 @@ const queries = useQueries({
|
|
|
142
143
|
})
|
|
143
144
|
|
|
144
145
|
// getQueryData
|
|
145
|
-
queryClient.getQueryData(usePost.getKey(variables)) //
|
|
146
|
+
queryClient.getQueryData(usePost.getKey(variables)) // Data
|
|
146
147
|
|
|
147
148
|
// setQueryData
|
|
148
149
|
queryClient.setQueryData(usePost.getKey(variables), {...})
|
|
@@ -177,12 +178,12 @@ Expose Methods
|
|
|
177
178
|
import { QueryClient, dehydrate } from '@tanstack/react-query'
|
|
178
179
|
import { createInfiniteQuery } from 'react-query-kit'
|
|
179
180
|
|
|
180
|
-
type
|
|
181
|
+
type Data = { projects: { id: string; name: string }[]; nextCursor: number }
|
|
181
182
|
type Variables = { active: boolean }
|
|
182
183
|
|
|
183
184
|
const useProjects = createInfiniteQuery({
|
|
184
185
|
queryKey: ['projects'],
|
|
185
|
-
fetcher: (variables: Variables, { pageParam }): Promise<
|
|
186
|
+
fetcher: (variables: Variables, { pageParam }): Promise<Data> => {
|
|
186
187
|
return fetch(
|
|
187
188
|
`/projects?cursor=${pageParam}?active=${variables.active}`
|
|
188
189
|
).then(res => res.json())
|
|
@@ -478,7 +479,7 @@ Middleware receive the hook and can execute logic before and after running it. I
|
|
|
478
479
|
import { QueryClient } from '@tanstack/react-query'
|
|
479
480
|
import { Middleware, MutationHook, QueryHook, getKey } from 'react-query-kit'
|
|
480
481
|
|
|
481
|
-
const logger: Middleware<QueryHook<
|
|
482
|
+
const logger: Middleware<QueryHook<Data, Variables>> = useQueryNext => {
|
|
482
483
|
return options => {
|
|
483
484
|
const log = useLogger()
|
|
484
485
|
const fetcher = (variables, context) => {
|
|
@@ -493,7 +494,7 @@ const logger: Middleware<QueryHook<Response, Variables>> = useQueryNext => {
|
|
|
493
494
|
}
|
|
494
495
|
}
|
|
495
496
|
|
|
496
|
-
const useUser = createQuery<
|
|
497
|
+
const useUser = createQuery<Data, Variables>({
|
|
497
498
|
use: [logger],
|
|
498
499
|
})
|
|
499
500
|
|
|
@@ -593,6 +594,45 @@ const useSomething = createQuery({
|
|
|
593
594
|
useSomething({...}, anotherQueryClient)
|
|
594
595
|
```
|
|
595
596
|
|
|
597
|
+
## TypeScript
|
|
598
|
+
|
|
599
|
+
By default, ReactQueryKit will also infer the types of `data` and `variables` from `fetcher`, so you can have the preferred types automatically.
|
|
600
|
+
|
|
601
|
+
```ts
|
|
602
|
+
type Data = { title: string; content: string }
|
|
603
|
+
type Variables = { id: number }
|
|
604
|
+
|
|
605
|
+
const usePost = createQuery({
|
|
606
|
+
queryKey: ['posts'],
|
|
607
|
+
fetcher: (variables: Variables): Promise<Data> => {
|
|
608
|
+
return fetch(`/posts/${variables}`).then(res => res.json())
|
|
609
|
+
},
|
|
610
|
+
})
|
|
611
|
+
|
|
612
|
+
// `data` will be inferred as `Data | undefined`.
|
|
613
|
+
// `variables` will be inferred as `Variables`.
|
|
614
|
+
const { data } = usePost({ variables: 1 })
|
|
615
|
+
```
|
|
616
|
+
|
|
617
|
+
You can also explicitly specify the types for `fetcher`‘s `variables` and `data`.
|
|
618
|
+
|
|
619
|
+
```ts
|
|
620
|
+
type Data = { title: string; content: string }
|
|
621
|
+
type Variables = { id: number }
|
|
622
|
+
|
|
623
|
+
const usePost = createQuery<Data, Variables, Error>({
|
|
624
|
+
queryKey: ['posts'],
|
|
625
|
+
fetcher: variables => {
|
|
626
|
+
return fetch(`/posts/${variables}`).then(res => res.json())
|
|
627
|
+
},
|
|
628
|
+
})
|
|
629
|
+
|
|
630
|
+
// `data` will be inferred as `Data | undefined`.
|
|
631
|
+
// `error` will be inferred as `Error | null`
|
|
632
|
+
// `variables` will be inferred as `Variables`.
|
|
633
|
+
const { data, error } = usePost({ variables: 1 })
|
|
634
|
+
```
|
|
635
|
+
|
|
596
636
|
## Type inference
|
|
597
637
|
|
|
598
638
|
You can extract the TypeScript type of any custom hook with `inferData` or `inferVariables`
|
|
@@ -600,10 +640,10 @@ You can extract the TypeScript type of any custom hook with `inferData` or `infe
|
|
|
600
640
|
```ts
|
|
601
641
|
import { inferData, inferFnData, inferError, inferVariables, inferOptions } from 'react-query-kit'
|
|
602
642
|
|
|
603
|
-
const useProjects = createInfiniteQuery<
|
|
643
|
+
const useProjects = createInfiniteQuery<Data, Variables, Error>(...)
|
|
604
644
|
|
|
605
|
-
inferData<typeof useProjects> // InfiniteData<
|
|
606
|
-
inferFnData<typeof useProjects> //
|
|
645
|
+
inferData<typeof useProjects> // InfiniteData<Data>
|
|
646
|
+
inferFnData<typeof useProjects> // Data
|
|
607
647
|
inferVariables<typeof useProjects> // Variables
|
|
608
648
|
inferError<typeof useProjects> // Error
|
|
609
649
|
inferOptions<typeof useProjects> // InfiniteQueryHookOptions<...>
|
package/build/lib/types.d.ts
CHANGED
|
@@ -101,18 +101,18 @@ export interface SuspenseInfiniteQueryHook<TFnData = unknown, TVariables = void,
|
|
|
101
101
|
<TData = CompatibleWithV4<InfiniteData<TFnData, TPageParam>, TFnData>>(options?: SuspenseInfiniteQueryHookOptions<TFnData, TError, TData, TVariables, TPageParam>, queryClient?: CompatibleWithV4<QueryClient, void>): SuspenseInfiniteQueryHookResult<TData, TError>;
|
|
102
102
|
}
|
|
103
103
|
export interface CreateMutationOptions<TData = unknown, TVariables = void, TError = CompatibleError, TContext = unknown> extends UseMutationOptions<TData, TError, TVariables, TContext> {
|
|
104
|
-
use?: Middleware<MutationHook<TData,
|
|
104
|
+
use?: Middleware<MutationHook<TData, TVariables, TError>>[];
|
|
105
105
|
}
|
|
106
|
-
export interface MutationHookOptions<TData, TError, TVariables, TContext> extends Omit<UseMutationOptions<TData,
|
|
107
|
-
use?: Middleware<MutationHook<TData,
|
|
106
|
+
export interface MutationHookOptions<TData, TError, TVariables, TContext> extends Omit<UseMutationOptions<TData, TVariables, TError, TContext>, 'mutationFn' | 'mutationKey'> {
|
|
107
|
+
use?: Middleware<MutationHook<TData, TVariables, TError>>[];
|
|
108
108
|
}
|
|
109
109
|
export type MutationHookResult<TData = unknown, TError = CompatibleError, TVariables = void, TContext = unknown> = UseMutationResult<TData, TError, TVariables, TContext>;
|
|
110
|
-
export interface ExposeMutationMethods<TData = unknown, TVariables = void, TError =
|
|
110
|
+
export interface ExposeMutationMethods<TData = unknown, TVariables = void, TError = CompatibleError, TDefaultContext = unknown> {
|
|
111
111
|
getKey: () => MutationKey | undefined;
|
|
112
112
|
getOptions: () => UseMutationOptions<TData, TError, TVariables, TDefaultContext>;
|
|
113
113
|
mutationFn: MutationFunction<TData, TVariables>;
|
|
114
114
|
}
|
|
115
|
-
export interface MutationHook<TData = unknown, TVariables = void, TError =
|
|
115
|
+
export interface MutationHook<TData = unknown, TVariables = void, TError = CompatibleError, TDefaultContext = unknown> extends ExposeMutationMethods<TData, TVariables, TError, TDefaultContext> {
|
|
116
116
|
<TContext = TDefaultContext>(options?: MutationHookOptions<TData, TError, TVariables, TContext>, queryClient?: CompatibleWithV4<QueryClient, void>): MutationHookResult<TData, TError, TVariables, TContext>;
|
|
117
117
|
}
|
|
118
118
|
export type inferVariables<T> = T extends {
|
|
@@ -126,7 +126,7 @@ export type inferFnData<T> = T extends {
|
|
|
126
126
|
} ? TFnData : T extends ExposeMutationMethods<infer TFnData, any, any, any> ? TFnData : never;
|
|
127
127
|
export type inferError<T> = T extends ExposeMethods<any, any, infer TError> ? TError : T extends ExposeMethods<any, any, infer TError, any> ? TError : T extends ExposeMutationMethods<any, any, infer TError, any> ? TError : never;
|
|
128
128
|
export type inferOptions<T> = T extends QueryHook<infer TFnData, infer TVariables, infer TError> ? QueryHookOptions<TFnData, TError, TFnData, TVariables> : T extends SuspenseQueryHook<infer TFnData, infer TVariables, infer TError> ? SuspenseQueryHookOptions<TFnData, TError, TFnData, TVariables> : T extends InfiniteQueryHook<infer TFnData, infer TVariables, infer TError, infer TPageParam> ? InfiniteQueryHookOptions<TFnData, TError, CompatibleWithV4<InfiniteData<TFnData, TPageParam>, TFnData>, TVariables, TPageParam> : T extends SuspenseInfiniteQueryHook<infer TFnData, infer TVariables, infer TError, infer TPageParam> ? SuspenseInfiniteQueryHookOptions<TFnData, TError, CompatibleWithV4<InfiniteData<TFnData, TPageParam>, TFnData>, TVariables, TPageParam> : T extends MutationHook<infer TFnData, infer TVariables, infer TError> ? MutationHookOptions<TFnData, TError, TVariables, unknown> : never;
|
|
129
|
-
export type inferCreateOptions<T> = T extends QueryHook<infer TFnData, infer TVariables, infer TError> ? CreateQueryOptions<TFnData, TVariables, TError> : T extends SuspenseQueryHook<infer TFnData, infer TVariables, infer TError> ? CreateSuspenseQueryOptions<TFnData, TVariables, TError> : T extends InfiniteQueryHook<infer TFnData, infer TVariables, infer TError, infer TPageParam> ? CreateInfiniteQueryOptions<TFnData, TVariables, TError, TPageParam> : T extends SuspenseInfiniteQueryHook<infer TFnData, infer TVariables, infer TError, infer TPageParam> ? CreateSuspenseInfiniteQueryOptions<TFnData, TVariables, TError, TPageParam> : T extends MutationHook<infer TFnData, infer TVariables, infer TError, infer TContext> ? CreateMutationOptions<TFnData,
|
|
129
|
+
export type inferCreateOptions<T> = T extends QueryHook<infer TFnData, infer TVariables, infer TError> ? CreateQueryOptions<TFnData, TVariables, TError> : T extends SuspenseQueryHook<infer TFnData, infer TVariables, infer TError> ? CreateSuspenseQueryOptions<TFnData, TVariables, TError> : T extends InfiniteQueryHook<infer TFnData, infer TVariables, infer TError, infer TPageParam> ? CreateInfiniteQueryOptions<TFnData, TVariables, TError, TPageParam> : T extends SuspenseInfiniteQueryHook<infer TFnData, infer TVariables, infer TError, infer TPageParam> ? CreateSuspenseInfiniteQueryOptions<TFnData, TVariables, TError, TPageParam> : T extends MutationHook<infer TFnData, infer TVariables, infer TError, infer TContext> ? CreateMutationOptions<TFnData, TVariables, TError, TContext> : never;
|
|
130
130
|
export type RouterQueryOptions<TFnData, TVariables = void, TError = CompatibleError> = Omit<CreateQueryOptions<TFnData, TVariables, TError>, 'queryKey'>;
|
|
131
131
|
export type RouterQuery<TFnData, TVariables = void, TError = CompatibleError> = RouterQueryOptions<TFnData, TVariables, TError> & {
|
|
132
132
|
_type: `q`;
|
package/build/stats-html.html
CHANGED
|
@@ -4014,7 +4014,7 @@ var drawChart = (function (exports) {
|
|
|
4014
4014
|
</script>
|
|
4015
4015
|
<script>
|
|
4016
4016
|
/*<!--*/
|
|
4017
|
-
const data = {"version":2,"tree":{"name":"root","children":[{"name":"zip.esm.js","children":[{"name":"src","children":[{"uid":"
|
|
4017
|
+
const data = {"version":2,"tree":{"name":"root","children":[{"name":"zip.esm.js","children":[{"name":"src","children":[{"uid":"1112-1","name":"utils.ts"},{"uid":"1112-3","name":"createBaseQuery.ts"},{"uid":"1112-5","name":"createQuery.ts"},{"uid":"1112-7","name":"createSuspenseQuery.ts"},{"uid":"1112-9","name":"createInfiniteQuery.ts"},{"uid":"1112-11","name":"createSuspenseInfiniteQuery.ts"},{"uid":"1112-13","name":"createMutation.ts"},{"uid":"1112-15","name":"router.ts"},{"uid":"1112-17","name":"index.ts"}]}]}],"isRoot":true},"nodeParts":{"1112-1":{"renderedLength":894,"gzipLength":449,"brotliLength":0,"mainUid":"1112-0"},"1112-3":{"renderedLength":1162,"gzipLength":397,"brotliLength":0,"mainUid":"1112-2"},"1112-5":{"renderedLength":91,"gzipLength":87,"brotliLength":0,"mainUid":"1112-4"},"1112-7":{"renderedLength":179,"gzipLength":118,"brotliLength":0,"mainUid":"1112-6"},"1112-9":{"renderedLength":107,"gzipLength":97,"brotliLength":0,"mainUid":"1112-8"},"1112-11":{"renderedLength":203,"gzipLength":128,"brotliLength":0,"mainUid":"1112-10"},"1112-13":{"renderedLength":271,"gzipLength":168,"brotliLength":0,"mainUid":"1112-12"},"1112-15":{"renderedLength":1152,"gzipLength":385,"brotliLength":0,"mainUid":"1112-14"},"1112-17":{"renderedLength":0,"gzipLength":0,"brotliLength":0,"mainUid":"1112-16"}},"nodeMetas":{"1112-0":{"id":"/src/utils.ts","moduleParts":{"zip.esm.js":"1112-1"},"imported":[{"uid":"1112-19"}],"importedBy":[{"uid":"1112-16"},{"uid":"1112-4"},{"uid":"1112-6"},{"uid":"1112-8"},{"uid":"1112-10"},{"uid":"1112-12"},{"uid":"1112-2"}]},"1112-2":{"id":"/src/createBaseQuery.ts","moduleParts":{"zip.esm.js":"1112-3"},"imported":[{"uid":"1112-0"}],"importedBy":[{"uid":"1112-4"},{"uid":"1112-6"},{"uid":"1112-8"},{"uid":"1112-10"}]},"1112-4":{"id":"/src/createQuery.ts","moduleParts":{"zip.esm.js":"1112-5"},"imported":[{"uid":"1112-2"},{"uid":"1112-0"}],"importedBy":[{"uid":"1112-16"},{"uid":"1112-14"}]},"1112-6":{"id":"/src/createSuspenseQuery.ts","moduleParts":{"zip.esm.js":"1112-7"},"imported":[{"uid":"1112-2"},{"uid":"1112-0"}],"importedBy":[{"uid":"1112-16"},{"uid":"1112-14"}]},"1112-8":{"id":"/src/createInfiniteQuery.ts","moduleParts":{"zip.esm.js":"1112-9"},"imported":[{"uid":"1112-2"},{"uid":"1112-0"}],"importedBy":[{"uid":"1112-16"},{"uid":"1112-14"}]},"1112-10":{"id":"/src/createSuspenseInfiniteQuery.ts","moduleParts":{"zip.esm.js":"1112-11"},"imported":[{"uid":"1112-2"},{"uid":"1112-0"}],"importedBy":[{"uid":"1112-16"},{"uid":"1112-14"}]},"1112-12":{"id":"/src/createMutation.ts","moduleParts":{"zip.esm.js":"1112-13"},"imported":[{"uid":"1112-0"}],"importedBy":[{"uid":"1112-16"},{"uid":"1112-14"}]},"1112-14":{"id":"/src/router.ts","moduleParts":{"zip.esm.js":"1112-15"},"imported":[{"uid":"1112-8"},{"uid":"1112-12"},{"uid":"1112-4"},{"uid":"1112-10"},{"uid":"1112-6"}],"importedBy":[{"uid":"1112-16"}]},"1112-16":{"id":"/src/index.ts","moduleParts":{"zip.esm.js":"1112-17"},"imported":[{"uid":"1112-4"},{"uid":"1112-6"},{"uid":"1112-8"},{"uid":"1112-10"},{"uid":"1112-12"},{"uid":"1112-18"},{"uid":"1112-14"},{"uid":"1112-0"}],"importedBy":[],"isEntry":true},"1112-18":{"id":"/src/types.ts","moduleParts":{},"imported":[],"importedBy":[{"uid":"1112-16"}]},"1112-19":{"id":"@tanstack/react-query","moduleParts":{},"imported":[],"importedBy":[{"uid":"1112-0"}],"isExternal":true}},"env":{"rollup":"2.77.2"},"options":{"gzip":true,"brotli":false,"sourcemap":false}};
|
|
4018
4018
|
|
|
4019
4019
|
const run = () => {
|
|
4020
4020
|
const width = window.innerWidth;
|
package/build/stats.json
CHANGED
|
@@ -10,39 +10,39 @@
|
|
|
10
10
|
"name": "src",
|
|
11
11
|
"children": [
|
|
12
12
|
{
|
|
13
|
-
"uid": "
|
|
13
|
+
"uid": "1112-21",
|
|
14
14
|
"name": "utils.ts"
|
|
15
15
|
},
|
|
16
16
|
{
|
|
17
|
-
"uid": "
|
|
17
|
+
"uid": "1112-23",
|
|
18
18
|
"name": "createBaseQuery.ts"
|
|
19
19
|
},
|
|
20
20
|
{
|
|
21
|
-
"uid": "
|
|
21
|
+
"uid": "1112-25",
|
|
22
22
|
"name": "createQuery.ts"
|
|
23
23
|
},
|
|
24
24
|
{
|
|
25
|
-
"uid": "
|
|
25
|
+
"uid": "1112-27",
|
|
26
26
|
"name": "createSuspenseQuery.ts"
|
|
27
27
|
},
|
|
28
28
|
{
|
|
29
|
-
"uid": "
|
|
29
|
+
"uid": "1112-29",
|
|
30
30
|
"name": "createInfiniteQuery.ts"
|
|
31
31
|
},
|
|
32
32
|
{
|
|
33
|
-
"uid": "
|
|
33
|
+
"uid": "1112-31",
|
|
34
34
|
"name": "createSuspenseInfiniteQuery.ts"
|
|
35
35
|
},
|
|
36
36
|
{
|
|
37
|
-
"uid": "
|
|
37
|
+
"uid": "1112-33",
|
|
38
38
|
"name": "createMutation.ts"
|
|
39
39
|
},
|
|
40
40
|
{
|
|
41
|
-
"uid": "
|
|
41
|
+
"uid": "1112-35",
|
|
42
42
|
"name": "router.ts"
|
|
43
43
|
},
|
|
44
44
|
{
|
|
45
|
-
"uid": "
|
|
45
|
+
"uid": "1112-37",
|
|
46
46
|
"name": "index.ts"
|
|
47
47
|
}
|
|
48
48
|
]
|
|
@@ -53,307 +53,307 @@
|
|
|
53
53
|
"isRoot": true
|
|
54
54
|
},
|
|
55
55
|
"nodeParts": {
|
|
56
|
-
"
|
|
56
|
+
"1112-21": {
|
|
57
57
|
"renderedLength": 894,
|
|
58
58
|
"gzipLength": 449,
|
|
59
59
|
"brotliLength": 0,
|
|
60
|
-
"mainUid": "
|
|
60
|
+
"mainUid": "1112-20"
|
|
61
61
|
},
|
|
62
|
-
"
|
|
62
|
+
"1112-23": {
|
|
63
63
|
"renderedLength": 1162,
|
|
64
64
|
"gzipLength": 397,
|
|
65
65
|
"brotliLength": 0,
|
|
66
|
-
"mainUid": "
|
|
66
|
+
"mainUid": "1112-22"
|
|
67
67
|
},
|
|
68
|
-
"
|
|
68
|
+
"1112-25": {
|
|
69
69
|
"renderedLength": 91,
|
|
70
70
|
"gzipLength": 87,
|
|
71
71
|
"brotliLength": 0,
|
|
72
|
-
"mainUid": "
|
|
72
|
+
"mainUid": "1112-24"
|
|
73
73
|
},
|
|
74
|
-
"
|
|
74
|
+
"1112-27": {
|
|
75
75
|
"renderedLength": 179,
|
|
76
76
|
"gzipLength": 118,
|
|
77
77
|
"brotliLength": 0,
|
|
78
|
-
"mainUid": "
|
|
78
|
+
"mainUid": "1112-26"
|
|
79
79
|
},
|
|
80
|
-
"
|
|
80
|
+
"1112-29": {
|
|
81
81
|
"renderedLength": 107,
|
|
82
82
|
"gzipLength": 97,
|
|
83
83
|
"brotliLength": 0,
|
|
84
|
-
"mainUid": "
|
|
84
|
+
"mainUid": "1112-28"
|
|
85
85
|
},
|
|
86
|
-
"
|
|
86
|
+
"1112-31": {
|
|
87
87
|
"renderedLength": 203,
|
|
88
88
|
"gzipLength": 128,
|
|
89
89
|
"brotliLength": 0,
|
|
90
|
-
"mainUid": "
|
|
90
|
+
"mainUid": "1112-30"
|
|
91
91
|
},
|
|
92
|
-
"
|
|
92
|
+
"1112-33": {
|
|
93
93
|
"renderedLength": 271,
|
|
94
94
|
"gzipLength": 168,
|
|
95
95
|
"brotliLength": 0,
|
|
96
|
-
"mainUid": "
|
|
96
|
+
"mainUid": "1112-32"
|
|
97
97
|
},
|
|
98
|
-
"
|
|
98
|
+
"1112-35": {
|
|
99
99
|
"renderedLength": 1152,
|
|
100
100
|
"gzipLength": 385,
|
|
101
101
|
"brotliLength": 0,
|
|
102
|
-
"mainUid": "
|
|
102
|
+
"mainUid": "1112-34"
|
|
103
103
|
},
|
|
104
|
-
"
|
|
104
|
+
"1112-37": {
|
|
105
105
|
"renderedLength": 0,
|
|
106
106
|
"gzipLength": 0,
|
|
107
107
|
"brotliLength": 0,
|
|
108
|
-
"mainUid": "
|
|
108
|
+
"mainUid": "1112-36"
|
|
109
109
|
}
|
|
110
110
|
},
|
|
111
111
|
"nodeMetas": {
|
|
112
|
-
"
|
|
112
|
+
"1112-20": {
|
|
113
113
|
"id": "/src/utils.ts",
|
|
114
114
|
"moduleParts": {
|
|
115
|
-
"zip.esm.js": "
|
|
115
|
+
"zip.esm.js": "1112-21"
|
|
116
116
|
},
|
|
117
117
|
"imported": [
|
|
118
118
|
{
|
|
119
|
-
"uid": "
|
|
119
|
+
"uid": "1112-39"
|
|
120
120
|
}
|
|
121
121
|
],
|
|
122
122
|
"importedBy": [
|
|
123
123
|
{
|
|
124
|
-
"uid": "
|
|
124
|
+
"uid": "1112-36"
|
|
125
125
|
},
|
|
126
126
|
{
|
|
127
|
-
"uid": "
|
|
127
|
+
"uid": "1112-24"
|
|
128
128
|
},
|
|
129
129
|
{
|
|
130
|
-
"uid": "
|
|
130
|
+
"uid": "1112-26"
|
|
131
131
|
},
|
|
132
132
|
{
|
|
133
|
-
"uid": "
|
|
133
|
+
"uid": "1112-28"
|
|
134
134
|
},
|
|
135
135
|
{
|
|
136
|
-
"uid": "
|
|
136
|
+
"uid": "1112-30"
|
|
137
137
|
},
|
|
138
138
|
{
|
|
139
|
-
"uid": "
|
|
139
|
+
"uid": "1112-32"
|
|
140
140
|
},
|
|
141
141
|
{
|
|
142
|
-
"uid": "
|
|
142
|
+
"uid": "1112-22"
|
|
143
143
|
}
|
|
144
144
|
]
|
|
145
145
|
},
|
|
146
|
-
"
|
|
146
|
+
"1112-22": {
|
|
147
147
|
"id": "/src/createBaseQuery.ts",
|
|
148
148
|
"moduleParts": {
|
|
149
|
-
"zip.esm.js": "
|
|
149
|
+
"zip.esm.js": "1112-23"
|
|
150
150
|
},
|
|
151
151
|
"imported": [
|
|
152
152
|
{
|
|
153
|
-
"uid": "
|
|
153
|
+
"uid": "1112-20"
|
|
154
154
|
}
|
|
155
155
|
],
|
|
156
156
|
"importedBy": [
|
|
157
157
|
{
|
|
158
|
-
"uid": "
|
|
158
|
+
"uid": "1112-24"
|
|
159
159
|
},
|
|
160
160
|
{
|
|
161
|
-
"uid": "
|
|
161
|
+
"uid": "1112-26"
|
|
162
162
|
},
|
|
163
163
|
{
|
|
164
|
-
"uid": "
|
|
164
|
+
"uid": "1112-28"
|
|
165
165
|
},
|
|
166
166
|
{
|
|
167
|
-
"uid": "
|
|
167
|
+
"uid": "1112-30"
|
|
168
168
|
}
|
|
169
169
|
]
|
|
170
170
|
},
|
|
171
|
-
"
|
|
171
|
+
"1112-24": {
|
|
172
172
|
"id": "/src/createQuery.ts",
|
|
173
173
|
"moduleParts": {
|
|
174
|
-
"zip.esm.js": "
|
|
174
|
+
"zip.esm.js": "1112-25"
|
|
175
175
|
},
|
|
176
176
|
"imported": [
|
|
177
177
|
{
|
|
178
|
-
"uid": "
|
|
178
|
+
"uid": "1112-22"
|
|
179
179
|
},
|
|
180
180
|
{
|
|
181
|
-
"uid": "
|
|
181
|
+
"uid": "1112-20"
|
|
182
182
|
}
|
|
183
183
|
],
|
|
184
184
|
"importedBy": [
|
|
185
185
|
{
|
|
186
|
-
"uid": "
|
|
186
|
+
"uid": "1112-36"
|
|
187
187
|
},
|
|
188
188
|
{
|
|
189
|
-
"uid": "
|
|
189
|
+
"uid": "1112-34"
|
|
190
190
|
}
|
|
191
191
|
]
|
|
192
192
|
},
|
|
193
|
-
"
|
|
193
|
+
"1112-26": {
|
|
194
194
|
"id": "/src/createSuspenseQuery.ts",
|
|
195
195
|
"moduleParts": {
|
|
196
|
-
"zip.esm.js": "
|
|
196
|
+
"zip.esm.js": "1112-27"
|
|
197
197
|
},
|
|
198
198
|
"imported": [
|
|
199
199
|
{
|
|
200
|
-
"uid": "
|
|
200
|
+
"uid": "1112-22"
|
|
201
201
|
},
|
|
202
202
|
{
|
|
203
|
-
"uid": "
|
|
203
|
+
"uid": "1112-20"
|
|
204
204
|
}
|
|
205
205
|
],
|
|
206
206
|
"importedBy": [
|
|
207
207
|
{
|
|
208
|
-
"uid": "
|
|
208
|
+
"uid": "1112-36"
|
|
209
209
|
},
|
|
210
210
|
{
|
|
211
|
-
"uid": "
|
|
211
|
+
"uid": "1112-34"
|
|
212
212
|
}
|
|
213
213
|
]
|
|
214
214
|
},
|
|
215
|
-
"
|
|
215
|
+
"1112-28": {
|
|
216
216
|
"id": "/src/createInfiniteQuery.ts",
|
|
217
217
|
"moduleParts": {
|
|
218
|
-
"zip.esm.js": "
|
|
218
|
+
"zip.esm.js": "1112-29"
|
|
219
219
|
},
|
|
220
220
|
"imported": [
|
|
221
221
|
{
|
|
222
|
-
"uid": "
|
|
222
|
+
"uid": "1112-22"
|
|
223
223
|
},
|
|
224
224
|
{
|
|
225
|
-
"uid": "
|
|
225
|
+
"uid": "1112-20"
|
|
226
226
|
}
|
|
227
227
|
],
|
|
228
228
|
"importedBy": [
|
|
229
229
|
{
|
|
230
|
-
"uid": "
|
|
230
|
+
"uid": "1112-36"
|
|
231
231
|
},
|
|
232
232
|
{
|
|
233
|
-
"uid": "
|
|
233
|
+
"uid": "1112-34"
|
|
234
234
|
}
|
|
235
235
|
]
|
|
236
236
|
},
|
|
237
|
-
"
|
|
237
|
+
"1112-30": {
|
|
238
238
|
"id": "/src/createSuspenseInfiniteQuery.ts",
|
|
239
239
|
"moduleParts": {
|
|
240
|
-
"zip.esm.js": "
|
|
240
|
+
"zip.esm.js": "1112-31"
|
|
241
241
|
},
|
|
242
242
|
"imported": [
|
|
243
243
|
{
|
|
244
|
-
"uid": "
|
|
244
|
+
"uid": "1112-22"
|
|
245
245
|
},
|
|
246
246
|
{
|
|
247
|
-
"uid": "
|
|
247
|
+
"uid": "1112-20"
|
|
248
248
|
}
|
|
249
249
|
],
|
|
250
250
|
"importedBy": [
|
|
251
251
|
{
|
|
252
|
-
"uid": "
|
|
252
|
+
"uid": "1112-36"
|
|
253
253
|
},
|
|
254
254
|
{
|
|
255
|
-
"uid": "
|
|
255
|
+
"uid": "1112-34"
|
|
256
256
|
}
|
|
257
257
|
]
|
|
258
258
|
},
|
|
259
|
-
"
|
|
259
|
+
"1112-32": {
|
|
260
260
|
"id": "/src/createMutation.ts",
|
|
261
261
|
"moduleParts": {
|
|
262
|
-
"zip.esm.js": "
|
|
262
|
+
"zip.esm.js": "1112-33"
|
|
263
263
|
},
|
|
264
264
|
"imported": [
|
|
265
265
|
{
|
|
266
|
-
"uid": "
|
|
266
|
+
"uid": "1112-20"
|
|
267
267
|
}
|
|
268
268
|
],
|
|
269
269
|
"importedBy": [
|
|
270
270
|
{
|
|
271
|
-
"uid": "
|
|
271
|
+
"uid": "1112-36"
|
|
272
272
|
},
|
|
273
273
|
{
|
|
274
|
-
"uid": "
|
|
274
|
+
"uid": "1112-34"
|
|
275
275
|
}
|
|
276
276
|
]
|
|
277
277
|
},
|
|
278
|
-
"
|
|
278
|
+
"1112-34": {
|
|
279
279
|
"id": "/src/router.ts",
|
|
280
280
|
"moduleParts": {
|
|
281
|
-
"zip.esm.js": "
|
|
281
|
+
"zip.esm.js": "1112-35"
|
|
282
282
|
},
|
|
283
283
|
"imported": [
|
|
284
284
|
{
|
|
285
|
-
"uid": "
|
|
285
|
+
"uid": "1112-28"
|
|
286
286
|
},
|
|
287
287
|
{
|
|
288
|
-
"uid": "
|
|
288
|
+
"uid": "1112-32"
|
|
289
289
|
},
|
|
290
290
|
{
|
|
291
|
-
"uid": "
|
|
291
|
+
"uid": "1112-24"
|
|
292
292
|
},
|
|
293
293
|
{
|
|
294
|
-
"uid": "
|
|
294
|
+
"uid": "1112-30"
|
|
295
295
|
},
|
|
296
296
|
{
|
|
297
|
-
"uid": "
|
|
297
|
+
"uid": "1112-26"
|
|
298
298
|
}
|
|
299
299
|
],
|
|
300
300
|
"importedBy": [
|
|
301
301
|
{
|
|
302
|
-
"uid": "
|
|
302
|
+
"uid": "1112-36"
|
|
303
303
|
}
|
|
304
304
|
]
|
|
305
305
|
},
|
|
306
|
-
"
|
|
306
|
+
"1112-36": {
|
|
307
307
|
"id": "/src/index.ts",
|
|
308
308
|
"moduleParts": {
|
|
309
|
-
"zip.esm.js": "
|
|
309
|
+
"zip.esm.js": "1112-37"
|
|
310
310
|
},
|
|
311
311
|
"imported": [
|
|
312
312
|
{
|
|
313
|
-
"uid": "
|
|
313
|
+
"uid": "1112-24"
|
|
314
314
|
},
|
|
315
315
|
{
|
|
316
|
-
"uid": "
|
|
316
|
+
"uid": "1112-26"
|
|
317
317
|
},
|
|
318
318
|
{
|
|
319
|
-
"uid": "
|
|
319
|
+
"uid": "1112-28"
|
|
320
320
|
},
|
|
321
321
|
{
|
|
322
|
-
"uid": "
|
|
322
|
+
"uid": "1112-30"
|
|
323
323
|
},
|
|
324
324
|
{
|
|
325
|
-
"uid": "
|
|
325
|
+
"uid": "1112-32"
|
|
326
326
|
},
|
|
327
327
|
{
|
|
328
|
-
"uid": "
|
|
328
|
+
"uid": "1112-38"
|
|
329
329
|
},
|
|
330
330
|
{
|
|
331
|
-
"uid": "
|
|
331
|
+
"uid": "1112-34"
|
|
332
332
|
},
|
|
333
333
|
{
|
|
334
|
-
"uid": "
|
|
334
|
+
"uid": "1112-20"
|
|
335
335
|
}
|
|
336
336
|
],
|
|
337
337
|
"importedBy": [],
|
|
338
338
|
"isEntry": true
|
|
339
339
|
},
|
|
340
|
-
"
|
|
340
|
+
"1112-38": {
|
|
341
341
|
"id": "/src/types.ts",
|
|
342
342
|
"moduleParts": {},
|
|
343
343
|
"imported": [],
|
|
344
344
|
"importedBy": [
|
|
345
345
|
{
|
|
346
|
-
"uid": "
|
|
346
|
+
"uid": "1112-36"
|
|
347
347
|
}
|
|
348
348
|
]
|
|
349
349
|
},
|
|
350
|
-
"
|
|
350
|
+
"1112-39": {
|
|
351
351
|
"id": "@tanstack/react-query",
|
|
352
352
|
"moduleParts": {},
|
|
353
353
|
"imported": [],
|
|
354
354
|
"importedBy": [
|
|
355
355
|
{
|
|
356
|
-
"uid": "
|
|
356
|
+
"uid": "1112-20"
|
|
357
357
|
}
|
|
358
358
|
],
|
|
359
359
|
"isExternal": true
|
package/package.json
CHANGED
package/src/types.ts
CHANGED
|
@@ -445,15 +445,15 @@ export interface CreateMutationOptions<
|
|
|
445
445
|
TError = CompatibleError,
|
|
446
446
|
TContext = unknown
|
|
447
447
|
> extends UseMutationOptions<TData, TError, TVariables, TContext> {
|
|
448
|
-
use?: Middleware<MutationHook<TData,
|
|
448
|
+
use?: Middleware<MutationHook<TData, TVariables, TError>>[]
|
|
449
449
|
}
|
|
450
450
|
|
|
451
451
|
export interface MutationHookOptions<TData, TError, TVariables, TContext>
|
|
452
452
|
extends Omit<
|
|
453
|
-
UseMutationOptions<TData,
|
|
453
|
+
UseMutationOptions<TData, TVariables, TError, TContext>,
|
|
454
454
|
'mutationFn' | 'mutationKey'
|
|
455
455
|
> {
|
|
456
|
-
use?: Middleware<MutationHook<TData,
|
|
456
|
+
use?: Middleware<MutationHook<TData, TVariables, TError>>[]
|
|
457
457
|
}
|
|
458
458
|
|
|
459
459
|
export type MutationHookResult<
|
|
@@ -466,7 +466,7 @@ export type MutationHookResult<
|
|
|
466
466
|
export interface ExposeMutationMethods<
|
|
467
467
|
TData = unknown,
|
|
468
468
|
TVariables = void,
|
|
469
|
-
TError =
|
|
469
|
+
TError = CompatibleError,
|
|
470
470
|
TDefaultContext = unknown
|
|
471
471
|
> {
|
|
472
472
|
getKey: () => MutationKey | undefined
|
|
@@ -482,7 +482,7 @@ export interface ExposeMutationMethods<
|
|
|
482
482
|
export interface MutationHook<
|
|
483
483
|
TData = unknown,
|
|
484
484
|
TVariables = void,
|
|
485
|
-
TError =
|
|
485
|
+
TError = CompatibleError,
|
|
486
486
|
TDefaultContext = unknown
|
|
487
487
|
> extends ExposeMutationMethods<TData, TVariables, TError, TDefaultContext> {
|
|
488
488
|
<TContext = TDefaultContext>(
|
|
@@ -593,7 +593,7 @@ export type inferCreateOptions<T> = T extends QueryHook<
|
|
|
593
593
|
infer TError,
|
|
594
594
|
infer TContext
|
|
595
595
|
>
|
|
596
|
-
? CreateMutationOptions<TFnData,
|
|
596
|
+
? CreateMutationOptions<TFnData, TVariables, TError, TContext>
|
|
597
597
|
: never
|
|
598
598
|
|
|
599
599
|
// router
|