react-query-kit 2.0.0 → 2.0.1
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 +56 -27
- package/build/lib/index.d.ts +1 -1
- package/build/lib/types.d.ts +3 -2
- package/build/stats-html.html +1 -1
- package/build/stats.json +77 -77
- package/package.json +1 -1
- package/src/index.ts +3 -0
- package/src/types.ts +14 -2
package/README.md
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
<a href="https://www.npmjs.com/package/react-query-kit"><img src="https://badgen.net/npm/v/react-query-kit" alt="Latest published version" target="\_parent"></a>
|
|
17
17
|
<a href="https://unpkg.com/browse/react-query-kit@latest/build/umd/index.production.js" rel="nofollow"><img src="https://img.badgesize.io/https:/unpkg.com/react-query-kit@latest/build/umd/index.production.js?label=gzip%20size&compression=gzip" alt="gzip size"></a>
|
|
18
18
|
<a href="https://github.com/liaoliao666/react-query-kit"><img src="https://badgen.net/npm/types/react-query-kit" alt="Types included" target="\_parent"></a>
|
|
19
|
-
<a href="https://
|
|
19
|
+
<a href="https://github.com/liaoliao666/react-query-kit/blob/main/LICENSE"><img src="https://badgen.net/npm/license/react-query-kit" alt="License" target="\_parent"></a>
|
|
20
20
|
<a href="https://www.npmjs.com/package/react-query-kit"><img src="https://badgen.net/npm/dt/react-query-kit" alt="Number of downloads" target="\_parent"></a>
|
|
21
21
|
<a href="https://github.com/liaoliao666/react-query-kit"><img src="https://img.shields.io/github/stars/liaoliao666/react-query-kit.svg?style=social&label=Star" alt="GitHub Stars" target="\_parent"></a>
|
|
22
22
|
</p>
|
|
@@ -378,22 +378,26 @@ Middleware receive the hook and can execute logic before and after running it. I
|
|
|
378
378
|
### Usage
|
|
379
379
|
|
|
380
380
|
```ts
|
|
381
|
+
import { QueryClient } from '@tanstack/react-query'
|
|
381
382
|
import { Middleware, MutationHook, QueryHook, getKey } from 'react-query-kit'
|
|
382
383
|
|
|
383
384
|
const myMiddleware: Middleware<
|
|
384
385
|
QueryHook<Response, Variables>
|
|
385
386
|
> = useQueryNext => {
|
|
386
|
-
return options => {
|
|
387
|
+
return (options, queryClient) => {
|
|
387
388
|
const { userId } = useAuth()
|
|
388
|
-
const client = useQueryClient()
|
|
389
|
+
const client = useQueryClient(queryClient)
|
|
389
390
|
const variables = options.variables ?? { id: userId }
|
|
390
391
|
const hasData = () => !!client.getQueryData(useUser.getKey(variables))
|
|
391
392
|
|
|
392
|
-
return useQueryNext(
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
393
|
+
return useQueryNext(
|
|
394
|
+
{
|
|
395
|
+
...options,
|
|
396
|
+
variables,
|
|
397
|
+
enabled: options.enabled ?? !hasData(),
|
|
398
|
+
},
|
|
399
|
+
queryClient
|
|
400
|
+
)
|
|
397
401
|
}
|
|
398
402
|
}
|
|
399
403
|
|
|
@@ -403,33 +407,57 @@ const useUser = createQuery<Response, Variables>({
|
|
|
403
407
|
})
|
|
404
408
|
|
|
405
409
|
// global middlewares
|
|
406
|
-
const
|
|
407
|
-
return options => {
|
|
408
|
-
|
|
409
|
-
const
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
return useQueryNext({
|
|
413
|
-
...options,
|
|
414
|
-
enabled: options.enabled ?? !hasData(),
|
|
415
|
-
})
|
|
410
|
+
const queryMiddleware: Middleware<QueryHook> = useQueryNext => {
|
|
411
|
+
return (options, queryClient) => {
|
|
412
|
+
// u can also get queryKey via function getKey
|
|
413
|
+
const queryKey = getKey(options.primaryKey, options.variables)
|
|
414
|
+
// ...
|
|
415
|
+
return useQueryNext(options, queryClient)
|
|
416
416
|
}
|
|
417
417
|
}
|
|
418
418
|
const mutationMiddleware: Middleware<MutationHook> = useMutationNext => {
|
|
419
|
-
return options => {
|
|
419
|
+
return (options, queryClient) => {
|
|
420
420
|
// ...
|
|
421
|
-
return useMutationNext(options)
|
|
421
|
+
return useMutationNext(options, queryClient)
|
|
422
422
|
}
|
|
423
423
|
}
|
|
424
424
|
|
|
425
|
-
const queryClient =
|
|
426
|
-
|
|
427
|
-
|
|
425
|
+
const queryClient = new QueryClient({
|
|
426
|
+
defaultOptions: {
|
|
427
|
+
queries: {
|
|
428
|
+
use: [queryMiddleware],
|
|
429
|
+
},
|
|
430
|
+
mutations: {
|
|
431
|
+
use: [mutationMiddleware],
|
|
432
|
+
},
|
|
428
433
|
},
|
|
429
|
-
|
|
430
|
-
|
|
434
|
+
})
|
|
435
|
+
```
|
|
436
|
+
|
|
437
|
+
### Extend
|
|
438
|
+
|
|
439
|
+
Middleware will be merged from superior. For example:
|
|
440
|
+
|
|
441
|
+
```jsx
|
|
442
|
+
const queryClient = new QueryClient({
|
|
443
|
+
defaultOptions: {
|
|
444
|
+
queries: {
|
|
445
|
+
use: [a],
|
|
446
|
+
},
|
|
431
447
|
},
|
|
432
448
|
})
|
|
449
|
+
|
|
450
|
+
const useSomething = createQuery({
|
|
451
|
+
use: [b],
|
|
452
|
+
})
|
|
453
|
+
|
|
454
|
+
useSomething({ use: [c] })
|
|
455
|
+
```
|
|
456
|
+
|
|
457
|
+
is equivalent to:
|
|
458
|
+
|
|
459
|
+
```js
|
|
460
|
+
createQuery({ use: [a, b, c] })
|
|
433
461
|
```
|
|
434
462
|
|
|
435
463
|
### Multiple Middleware
|
|
@@ -457,13 +485,14 @@ exit a
|
|
|
457
485
|
You can extract the TypeScript type of any custom hook with `inferData` or `inferVariables`
|
|
458
486
|
|
|
459
487
|
```ts
|
|
460
|
-
import { inferData, inferFnData, inferVariables, inferOptions } from 'react-query-kit'
|
|
488
|
+
import { inferData, inferFnData, inferError, inferVariables, inferOptions } from 'react-query-kit'
|
|
461
489
|
|
|
462
|
-
const useProjects = createInfiniteQuery<Response, Variables>(...)
|
|
490
|
+
const useProjects = createInfiniteQuery<Response, Variables, Error>(...)
|
|
463
491
|
|
|
464
492
|
inferData<typeof useProjects> // InfiniteData<Response>
|
|
465
493
|
inferFnData<typeof useProjects> // Response
|
|
466
494
|
inferVariables<typeof useProjects> // Variables
|
|
495
|
+
inferError<typeof useProjects> // Error
|
|
467
496
|
inferOptions<typeof useProjects> // InfiniteQueryHookOptions<...>
|
|
468
497
|
```
|
|
469
498
|
|
package/build/lib/index.d.ts
CHANGED
|
@@ -4,4 +4,4 @@ export * from './createInfiniteQuery';
|
|
|
4
4
|
export * from './createSuspenseInfiniteQuery';
|
|
5
5
|
export * from './createMutation';
|
|
6
6
|
export { getKey } from './utils';
|
|
7
|
-
export type { CreateQueryOptions, QueryHookOptions, QueryHook, QueryHookResult, CreateInfiniteQueryOptions, InfiniteQueryHookOptions, InfiniteQueryHook, InfiniteQueryHookResult, CreateSuspenseQueryOptions, SuspenseQueryHook, SuspenseQueryHookOptions, SuspenseQueryHookResult, CreateSuspenseInfiniteQueryOptions, SuspenseInfiniteQueryHook, SuspenseInfiniteQueryHookOptions, SuspenseInfiniteQueryHookResult, MutationHookOptions, MutationHook, inferVariables, inferData, inferFnData, inferOptions, Middleware, } from './types';
|
|
7
|
+
export type { CreateQueryOptions, QueryHookOptions, QueryHook, QueryHookResult, CreateInfiniteQueryOptions, InfiniteQueryHookOptions, InfiniteQueryHook, InfiniteQueryHookResult, CreateSuspenseQueryOptions, SuspenseQueryHook, SuspenseQueryHookOptions, SuspenseQueryHookResult, CreateSuspenseInfiniteQueryOptions, SuspenseInfiniteQueryHook, SuspenseInfiniteQueryHookOptions, SuspenseInfiniteQueryHookResult, CreateMutationOptions, MutationHookOptions, MutationHook, inferVariables, inferData, inferFnData, inferOptions, inferError, inferCreateOptions, Middleware, } from './types';
|
package/build/lib/types.d.ts
CHANGED
|
@@ -17,8 +17,8 @@ export type AdditionalCreateOptions<TFnData, TVariables, TPageParam = never> = {
|
|
|
17
17
|
queryFn: CompatibleQueryFunction<TFnData, inferQueryKey<TVariables>, TPageParam>;
|
|
18
18
|
variables?: TVariables;
|
|
19
19
|
};
|
|
20
|
-
type
|
|
21
|
-
export type Middleware<T extends (...args: any) => any = QueryHook<any, any, any>> = (hook:
|
|
20
|
+
type inferMiddlewareHook<T extends (...args: any) => any> = (options: inferCreateOptions<T>, queryClient?: CompatibleWithV4<QueryClient, void>) => ReturnType<T>;
|
|
21
|
+
export type Middleware<T extends (...args: any) => any = QueryHook<any, any, any>> = (hook: inferMiddlewareHook<T>) => inferMiddlewareHook<T>;
|
|
22
22
|
export type DeepPartial<T> = T extends object ? {
|
|
23
23
|
[P in keyof T]?: DeepPartial<T[P]>;
|
|
24
24
|
} : T;
|
|
@@ -97,6 +97,7 @@ export interface MutationHook<TData = unknown, TVariables = any, TError = unknow
|
|
|
97
97
|
export type inferVariables<T> = T extends QueryHook<any, infer TVariables, any> ? TVariables : T extends SuspenseQueryHook<any, infer TVariables, any> ? TVariables : T extends InfiniteQueryHook<any, infer TVariables, any> ? TVariables : T extends SuspenseInfiniteQueryHook<any, infer TVariables, any> ? TVariables : T extends MutationHook<any, infer TVariables, any> ? TVariables : never;
|
|
98
98
|
export type inferData<T> = T extends QueryHook<infer TData, any, any> ? TData : T extends SuspenseQueryHook<infer TData, any, any> ? TData : T extends InfiniteQueryHook<infer TData, any, any, infer TPageParam> ? CompatibleWithV4<InfiniteData<TData, TPageParam>, InfiniteData<TData>> : T extends SuspenseInfiniteQueryHook<infer TData, any, any, infer TPageParam> ? CompatibleWithV4<InfiniteData<TData, TPageParam>, InfiniteData<TData>> : T extends MutationHook<infer TData, any, any> ? TData : never;
|
|
99
99
|
export type inferFnData<T> = T extends QueryHook<infer TData, any, any> ? TData : T extends SuspenseQueryHook<infer TData, any, any> ? TData : T extends InfiniteQueryHook<infer TData, any, any> ? TData : T extends SuspenseInfiniteQueryHook<infer TData, any, any> ? TData : T extends MutationHook<infer TData, any, any> ? TData : never;
|
|
100
|
+
export type inferError<T> = T extends QueryHook<any, any, infer TError> ? TError : T extends SuspenseQueryHook<any, any, infer TError> ? TError : T extends InfiniteQueryHook<any, any, infer TError> ? TError : T extends SuspenseInfiniteQueryHook<any, any, infer TError> ? TError : T extends MutationHook<any, any, infer TError> ? TError : never;
|
|
100
101
|
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;
|
|
101
102
|
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> ? CreateMutationOptions<TFnData, TError, TVariables, unknown> : never;
|
|
102
103
|
export {};
|
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":"index.production.js","children":[{"name":"src","children":[{"uid":"
|
|
4017
|
+
const data = {"version":2,"tree":{"name":"root","children":[{"name":"index.production.js","children":[{"name":"src","children":[{"uid":"a10d-1","name":"utils.ts"},{"uid":"a10d-3","name":"createBaseQuery.ts"},{"uid":"a10d-5","name":"createQuery.tsx"},{"uid":"a10d-7","name":"createSuspenseQuery.ts"},{"uid":"a10d-9","name":"createInfiniteQuery.ts"},{"uid":"a10d-11","name":"createSuspenseInfiniteQuery.ts"},{"uid":"a10d-13","name":"createMutation.ts"},{"uid":"a10d-15","name":"index.ts"}]}]}],"isRoot":true},"nodeParts":{"a10d-1":{"renderedLength":831,"gzipLength":395,"brotliLength":0,"mainUid":"a10d-0"},"a10d-3":{"renderedLength":999,"gzipLength":361,"brotliLength":0,"mainUid":"a10d-2"},"a10d-5":{"renderedLength":97,"gzipLength":90,"brotliLength":0,"mainUid":"a10d-4"},"a10d-7":{"renderedLength":271,"gzipLength":177,"brotliLength":0,"mainUid":"a10d-6"},"a10d-9":{"renderedLength":113,"gzipLength":99,"brotliLength":0,"mainUid":"a10d-8"},"a10d-11":{"renderedLength":287,"gzipLength":186,"brotliLength":0,"mainUid":"a10d-10"},"a10d-13":{"renderedLength":265,"gzipLength":173,"brotliLength":0,"mainUid":"a10d-12"},"a10d-15":{"renderedLength":0,"gzipLength":0,"brotliLength":0,"mainUid":"a10d-14"}},"nodeMetas":{"a10d-0":{"id":"/src/utils.ts","moduleParts":{"index.production.js":"a10d-1"},"imported":[{"uid":"a10d-16"}],"importedBy":[{"uid":"a10d-14"},{"uid":"a10d-12"},{"uid":"a10d-2"}]},"a10d-2":{"id":"/src/createBaseQuery.ts","moduleParts":{"index.production.js":"a10d-3"},"imported":[{"uid":"a10d-0"}],"importedBy":[{"uid":"a10d-4"},{"uid":"a10d-6"},{"uid":"a10d-8"},{"uid":"a10d-10"}]},"a10d-4":{"id":"/src/createQuery.tsx","moduleParts":{"index.production.js":"a10d-5"},"imported":[{"uid":"a10d-16"},{"uid":"a10d-2"}],"importedBy":[{"uid":"a10d-14"}]},"a10d-6":{"id":"/src/createSuspenseQuery.ts","moduleParts":{"index.production.js":"a10d-7"},"imported":[{"uid":"a10d-16"},{"uid":"a10d-2"}],"importedBy":[{"uid":"a10d-14"}]},"a10d-8":{"id":"/src/createInfiniteQuery.ts","moduleParts":{"index.production.js":"a10d-9"},"imported":[{"uid":"a10d-16"},{"uid":"a10d-2"}],"importedBy":[{"uid":"a10d-14"}]},"a10d-10":{"id":"/src/createSuspenseInfiniteQuery.ts","moduleParts":{"index.production.js":"a10d-11"},"imported":[{"uid":"a10d-16"},{"uid":"a10d-2"}],"importedBy":[{"uid":"a10d-14"}]},"a10d-12":{"id":"/src/createMutation.ts","moduleParts":{"index.production.js":"a10d-13"},"imported":[{"uid":"a10d-16"},{"uid":"a10d-0"}],"importedBy":[{"uid":"a10d-14"}]},"a10d-14":{"id":"/src/index.ts","moduleParts":{"index.production.js":"a10d-15"},"imported":[{"uid":"a10d-4"},{"uid":"a10d-6"},{"uid":"a10d-8"},{"uid":"a10d-10"},{"uid":"a10d-12"},{"uid":"a10d-0"}],"importedBy":[],"isEntry":true},"a10d-16":{"id":"@tanstack/react-query","moduleParts":{},"imported":[],"importedBy":[{"uid":"a10d-4"},{"uid":"a10d-6"},{"uid":"a10d-8"},{"uid":"a10d-10"},{"uid":"a10d-12"},{"uid":"a10d-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,35 +10,35 @@
|
|
|
10
10
|
"name": "src",
|
|
11
11
|
"children": [
|
|
12
12
|
{
|
|
13
|
-
"uid": "
|
|
13
|
+
"uid": "a10d-18",
|
|
14
14
|
"name": "utils.ts"
|
|
15
15
|
},
|
|
16
16
|
{
|
|
17
|
-
"uid": "
|
|
17
|
+
"uid": "a10d-20",
|
|
18
18
|
"name": "createBaseQuery.ts"
|
|
19
19
|
},
|
|
20
20
|
{
|
|
21
|
-
"uid": "
|
|
21
|
+
"uid": "a10d-22",
|
|
22
22
|
"name": "createQuery.tsx"
|
|
23
23
|
},
|
|
24
24
|
{
|
|
25
|
-
"uid": "
|
|
25
|
+
"uid": "a10d-24",
|
|
26
26
|
"name": "createSuspenseQuery.ts"
|
|
27
27
|
},
|
|
28
28
|
{
|
|
29
|
-
"uid": "
|
|
29
|
+
"uid": "a10d-26",
|
|
30
30
|
"name": "createInfiniteQuery.ts"
|
|
31
31
|
},
|
|
32
32
|
{
|
|
33
|
-
"uid": "
|
|
33
|
+
"uid": "a10d-28",
|
|
34
34
|
"name": "createSuspenseInfiniteQuery.ts"
|
|
35
35
|
},
|
|
36
36
|
{
|
|
37
|
-
"uid": "
|
|
37
|
+
"uid": "a10d-30",
|
|
38
38
|
"name": "createMutation.ts"
|
|
39
39
|
},
|
|
40
40
|
{
|
|
41
|
-
"uid": "
|
|
41
|
+
"uid": "a10d-32",
|
|
42
42
|
"name": "index.ts"
|
|
43
43
|
}
|
|
44
44
|
]
|
|
@@ -49,248 +49,248 @@
|
|
|
49
49
|
"isRoot": true
|
|
50
50
|
},
|
|
51
51
|
"nodeParts": {
|
|
52
|
-
"
|
|
52
|
+
"a10d-18": {
|
|
53
53
|
"renderedLength": 831,
|
|
54
54
|
"gzipLength": 395,
|
|
55
55
|
"brotliLength": 0,
|
|
56
|
-
"mainUid": "
|
|
56
|
+
"mainUid": "a10d-17"
|
|
57
57
|
},
|
|
58
|
-
"
|
|
58
|
+
"a10d-20": {
|
|
59
59
|
"renderedLength": 999,
|
|
60
60
|
"gzipLength": 361,
|
|
61
61
|
"brotliLength": 0,
|
|
62
|
-
"mainUid": "
|
|
62
|
+
"mainUid": "a10d-19"
|
|
63
63
|
},
|
|
64
|
-
"
|
|
64
|
+
"a10d-22": {
|
|
65
65
|
"renderedLength": 97,
|
|
66
66
|
"gzipLength": 90,
|
|
67
67
|
"brotliLength": 0,
|
|
68
|
-
"mainUid": "
|
|
68
|
+
"mainUid": "a10d-21"
|
|
69
69
|
},
|
|
70
|
-
"
|
|
70
|
+
"a10d-24": {
|
|
71
71
|
"renderedLength": 271,
|
|
72
72
|
"gzipLength": 177,
|
|
73
73
|
"brotliLength": 0,
|
|
74
|
-
"mainUid": "
|
|
74
|
+
"mainUid": "a10d-23"
|
|
75
75
|
},
|
|
76
|
-
"
|
|
76
|
+
"a10d-26": {
|
|
77
77
|
"renderedLength": 113,
|
|
78
78
|
"gzipLength": 99,
|
|
79
79
|
"brotliLength": 0,
|
|
80
|
-
"mainUid": "
|
|
80
|
+
"mainUid": "a10d-25"
|
|
81
81
|
},
|
|
82
|
-
"
|
|
82
|
+
"a10d-28": {
|
|
83
83
|
"renderedLength": 287,
|
|
84
84
|
"gzipLength": 186,
|
|
85
85
|
"brotliLength": 0,
|
|
86
|
-
"mainUid": "
|
|
86
|
+
"mainUid": "a10d-27"
|
|
87
87
|
},
|
|
88
|
-
"
|
|
88
|
+
"a10d-30": {
|
|
89
89
|
"renderedLength": 265,
|
|
90
90
|
"gzipLength": 173,
|
|
91
91
|
"brotliLength": 0,
|
|
92
|
-
"mainUid": "
|
|
92
|
+
"mainUid": "a10d-29"
|
|
93
93
|
},
|
|
94
|
-
"
|
|
94
|
+
"a10d-32": {
|
|
95
95
|
"renderedLength": 0,
|
|
96
96
|
"gzipLength": 0,
|
|
97
97
|
"brotliLength": 0,
|
|
98
|
-
"mainUid": "
|
|
98
|
+
"mainUid": "a10d-31"
|
|
99
99
|
}
|
|
100
100
|
},
|
|
101
101
|
"nodeMetas": {
|
|
102
|
-
"
|
|
102
|
+
"a10d-17": {
|
|
103
103
|
"id": "/src/utils.ts",
|
|
104
104
|
"moduleParts": {
|
|
105
|
-
"index.production.js": "
|
|
105
|
+
"index.production.js": "a10d-18"
|
|
106
106
|
},
|
|
107
107
|
"imported": [
|
|
108
108
|
{
|
|
109
|
-
"uid": "
|
|
109
|
+
"uid": "a10d-33"
|
|
110
110
|
}
|
|
111
111
|
],
|
|
112
112
|
"importedBy": [
|
|
113
113
|
{
|
|
114
|
-
"uid": "
|
|
114
|
+
"uid": "a10d-31"
|
|
115
115
|
},
|
|
116
116
|
{
|
|
117
|
-
"uid": "
|
|
117
|
+
"uid": "a10d-29"
|
|
118
118
|
},
|
|
119
119
|
{
|
|
120
|
-
"uid": "
|
|
120
|
+
"uid": "a10d-19"
|
|
121
121
|
}
|
|
122
122
|
]
|
|
123
123
|
},
|
|
124
|
-
"
|
|
124
|
+
"a10d-19": {
|
|
125
125
|
"id": "/src/createBaseQuery.ts",
|
|
126
126
|
"moduleParts": {
|
|
127
|
-
"index.production.js": "
|
|
127
|
+
"index.production.js": "a10d-20"
|
|
128
128
|
},
|
|
129
129
|
"imported": [
|
|
130
130
|
{
|
|
131
|
-
"uid": "
|
|
131
|
+
"uid": "a10d-17"
|
|
132
132
|
}
|
|
133
133
|
],
|
|
134
134
|
"importedBy": [
|
|
135
135
|
{
|
|
136
|
-
"uid": "
|
|
136
|
+
"uid": "a10d-21"
|
|
137
137
|
},
|
|
138
138
|
{
|
|
139
|
-
"uid": "
|
|
139
|
+
"uid": "a10d-23"
|
|
140
140
|
},
|
|
141
141
|
{
|
|
142
|
-
"uid": "
|
|
142
|
+
"uid": "a10d-25"
|
|
143
143
|
},
|
|
144
144
|
{
|
|
145
|
-
"uid": "
|
|
145
|
+
"uid": "a10d-27"
|
|
146
146
|
}
|
|
147
147
|
]
|
|
148
148
|
},
|
|
149
|
-
"
|
|
149
|
+
"a10d-21": {
|
|
150
150
|
"id": "/src/createQuery.tsx",
|
|
151
151
|
"moduleParts": {
|
|
152
|
-
"index.production.js": "
|
|
152
|
+
"index.production.js": "a10d-22"
|
|
153
153
|
},
|
|
154
154
|
"imported": [
|
|
155
155
|
{
|
|
156
|
-
"uid": "
|
|
156
|
+
"uid": "a10d-33"
|
|
157
157
|
},
|
|
158
158
|
{
|
|
159
|
-
"uid": "
|
|
159
|
+
"uid": "a10d-19"
|
|
160
160
|
}
|
|
161
161
|
],
|
|
162
162
|
"importedBy": [
|
|
163
163
|
{
|
|
164
|
-
"uid": "
|
|
164
|
+
"uid": "a10d-31"
|
|
165
165
|
}
|
|
166
166
|
]
|
|
167
167
|
},
|
|
168
|
-
"
|
|
168
|
+
"a10d-23": {
|
|
169
169
|
"id": "/src/createSuspenseQuery.ts",
|
|
170
170
|
"moduleParts": {
|
|
171
|
-
"index.production.js": "
|
|
171
|
+
"index.production.js": "a10d-24"
|
|
172
172
|
},
|
|
173
173
|
"imported": [
|
|
174
174
|
{
|
|
175
|
-
"uid": "
|
|
175
|
+
"uid": "a10d-33"
|
|
176
176
|
},
|
|
177
177
|
{
|
|
178
|
-
"uid": "
|
|
178
|
+
"uid": "a10d-19"
|
|
179
179
|
}
|
|
180
180
|
],
|
|
181
181
|
"importedBy": [
|
|
182
182
|
{
|
|
183
|
-
"uid": "
|
|
183
|
+
"uid": "a10d-31"
|
|
184
184
|
}
|
|
185
185
|
]
|
|
186
186
|
},
|
|
187
|
-
"
|
|
187
|
+
"a10d-25": {
|
|
188
188
|
"id": "/src/createInfiniteQuery.ts",
|
|
189
189
|
"moduleParts": {
|
|
190
|
-
"index.production.js": "
|
|
190
|
+
"index.production.js": "a10d-26"
|
|
191
191
|
},
|
|
192
192
|
"imported": [
|
|
193
193
|
{
|
|
194
|
-
"uid": "
|
|
194
|
+
"uid": "a10d-33"
|
|
195
195
|
},
|
|
196
196
|
{
|
|
197
|
-
"uid": "
|
|
197
|
+
"uid": "a10d-19"
|
|
198
198
|
}
|
|
199
199
|
],
|
|
200
200
|
"importedBy": [
|
|
201
201
|
{
|
|
202
|
-
"uid": "
|
|
202
|
+
"uid": "a10d-31"
|
|
203
203
|
}
|
|
204
204
|
]
|
|
205
205
|
},
|
|
206
|
-
"
|
|
206
|
+
"a10d-27": {
|
|
207
207
|
"id": "/src/createSuspenseInfiniteQuery.ts",
|
|
208
208
|
"moduleParts": {
|
|
209
|
-
"index.production.js": "
|
|
209
|
+
"index.production.js": "a10d-28"
|
|
210
210
|
},
|
|
211
211
|
"imported": [
|
|
212
212
|
{
|
|
213
|
-
"uid": "
|
|
213
|
+
"uid": "a10d-33"
|
|
214
214
|
},
|
|
215
215
|
{
|
|
216
|
-
"uid": "
|
|
216
|
+
"uid": "a10d-19"
|
|
217
217
|
}
|
|
218
218
|
],
|
|
219
219
|
"importedBy": [
|
|
220
220
|
{
|
|
221
|
-
"uid": "
|
|
221
|
+
"uid": "a10d-31"
|
|
222
222
|
}
|
|
223
223
|
]
|
|
224
224
|
},
|
|
225
|
-
"
|
|
225
|
+
"a10d-29": {
|
|
226
226
|
"id": "/src/createMutation.ts",
|
|
227
227
|
"moduleParts": {
|
|
228
|
-
"index.production.js": "
|
|
228
|
+
"index.production.js": "a10d-30"
|
|
229
229
|
},
|
|
230
230
|
"imported": [
|
|
231
231
|
{
|
|
232
|
-
"uid": "
|
|
232
|
+
"uid": "a10d-33"
|
|
233
233
|
},
|
|
234
234
|
{
|
|
235
|
-
"uid": "
|
|
235
|
+
"uid": "a10d-17"
|
|
236
236
|
}
|
|
237
237
|
],
|
|
238
238
|
"importedBy": [
|
|
239
239
|
{
|
|
240
|
-
"uid": "
|
|
240
|
+
"uid": "a10d-31"
|
|
241
241
|
}
|
|
242
242
|
]
|
|
243
243
|
},
|
|
244
|
-
"
|
|
244
|
+
"a10d-31": {
|
|
245
245
|
"id": "/src/index.ts",
|
|
246
246
|
"moduleParts": {
|
|
247
|
-
"index.production.js": "
|
|
247
|
+
"index.production.js": "a10d-32"
|
|
248
248
|
},
|
|
249
249
|
"imported": [
|
|
250
250
|
{
|
|
251
|
-
"uid": "
|
|
251
|
+
"uid": "a10d-21"
|
|
252
252
|
},
|
|
253
253
|
{
|
|
254
|
-
"uid": "
|
|
254
|
+
"uid": "a10d-23"
|
|
255
255
|
},
|
|
256
256
|
{
|
|
257
|
-
"uid": "
|
|
257
|
+
"uid": "a10d-25"
|
|
258
258
|
},
|
|
259
259
|
{
|
|
260
|
-
"uid": "
|
|
260
|
+
"uid": "a10d-27"
|
|
261
261
|
},
|
|
262
262
|
{
|
|
263
|
-
"uid": "
|
|
263
|
+
"uid": "a10d-29"
|
|
264
264
|
},
|
|
265
265
|
{
|
|
266
|
-
"uid": "
|
|
266
|
+
"uid": "a10d-17"
|
|
267
267
|
}
|
|
268
268
|
],
|
|
269
269
|
"importedBy": [],
|
|
270
270
|
"isEntry": true
|
|
271
271
|
},
|
|
272
|
-
"
|
|
272
|
+
"a10d-33": {
|
|
273
273
|
"id": "@tanstack/react-query",
|
|
274
274
|
"moduleParts": {},
|
|
275
275
|
"imported": [],
|
|
276
276
|
"importedBy": [
|
|
277
277
|
{
|
|
278
|
-
"uid": "
|
|
278
|
+
"uid": "a10d-21"
|
|
279
279
|
},
|
|
280
280
|
{
|
|
281
|
-
"uid": "
|
|
281
|
+
"uid": "a10d-23"
|
|
282
282
|
},
|
|
283
283
|
{
|
|
284
|
-
"uid": "
|
|
284
|
+
"uid": "a10d-25"
|
|
285
285
|
},
|
|
286
286
|
{
|
|
287
|
-
"uid": "
|
|
287
|
+
"uid": "a10d-27"
|
|
288
288
|
},
|
|
289
289
|
{
|
|
290
|
-
"uid": "
|
|
290
|
+
"uid": "a10d-29"
|
|
291
291
|
},
|
|
292
292
|
{
|
|
293
|
-
"uid": "
|
|
293
|
+
"uid": "a10d-17"
|
|
294
294
|
}
|
|
295
295
|
],
|
|
296
296
|
"isExternal": true
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -21,11 +21,14 @@ export type {
|
|
|
21
21
|
SuspenseInfiniteQueryHook,
|
|
22
22
|
SuspenseInfiniteQueryHookOptions,
|
|
23
23
|
SuspenseInfiniteQueryHookResult,
|
|
24
|
+
CreateMutationOptions,
|
|
24
25
|
MutationHookOptions,
|
|
25
26
|
MutationHook,
|
|
26
27
|
inferVariables,
|
|
27
28
|
inferData,
|
|
28
29
|
inferFnData,
|
|
29
30
|
inferOptions,
|
|
31
|
+
inferError,
|
|
32
|
+
inferCreateOptions,
|
|
30
33
|
Middleware,
|
|
31
34
|
} from './types'
|
package/src/types.ts
CHANGED
|
@@ -94,14 +94,14 @@ export type AdditionalCreateOptions<TFnData, TVariables, TPageParam = never> = {
|
|
|
94
94
|
variables?: TVariables
|
|
95
95
|
}
|
|
96
96
|
|
|
97
|
-
type
|
|
97
|
+
type inferMiddlewareHook<T extends (...args: any) => any> = (
|
|
98
98
|
options: inferCreateOptions<T>,
|
|
99
99
|
queryClient?: CompatibleWithV4<QueryClient, void>
|
|
100
100
|
) => ReturnType<T>
|
|
101
101
|
|
|
102
102
|
export type Middleware<
|
|
103
103
|
T extends (...args: any) => any = QueryHook<any, any, any>
|
|
104
|
-
> = (hook:
|
|
104
|
+
> = (hook: inferMiddlewareHook<T>) => inferMiddlewareHook<T>
|
|
105
105
|
|
|
106
106
|
export type DeepPartial<T> = T extends object
|
|
107
107
|
? {
|
|
@@ -458,6 +458,18 @@ export type inferFnData<T> = T extends QueryHook<infer TData, any, any>
|
|
|
458
458
|
? TData
|
|
459
459
|
: never
|
|
460
460
|
|
|
461
|
+
export type inferError<T> = T extends QueryHook<any, any, infer TError>
|
|
462
|
+
? TError
|
|
463
|
+
: T extends SuspenseQueryHook<any, any, infer TError>
|
|
464
|
+
? TError
|
|
465
|
+
: T extends InfiniteQueryHook<any, any, infer TError>
|
|
466
|
+
? TError
|
|
467
|
+
: T extends SuspenseInfiniteQueryHook<any, any, infer TError>
|
|
468
|
+
? TError
|
|
469
|
+
: T extends MutationHook<any, any, infer TError>
|
|
470
|
+
? TError
|
|
471
|
+
: never
|
|
472
|
+
|
|
461
473
|
export type inferOptions<T> = T extends QueryHook<
|
|
462
474
|
infer TFnData,
|
|
463
475
|
infer TVariables,
|