react-query-kit 1.5.1 → 2.0.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 +42 -72
- package/build/lib/createBaseQuery.d.ts +3 -2
- package/build/lib/createBaseQuery.esm.js +26 -32
- package/build/lib/createBaseQuery.esm.js.map +1 -1
- package/build/lib/createBaseQuery.js +23 -29
- package/build/lib/createBaseQuery.js.map +1 -1
- package/build/lib/createBaseQuery.mjs +26 -32
- package/build/lib/createBaseQuery.mjs.map +1 -1
- package/build/lib/createInfiniteQuery.d.ts +2 -5
- package/build/lib/createInfiniteQuery.esm.js +2 -2
- package/build/lib/createInfiniteQuery.esm.js.map +1 -1
- package/build/lib/createInfiniteQuery.js +2 -2
- package/build/lib/createInfiniteQuery.js.map +1 -1
- package/build/lib/createInfiniteQuery.mjs +2 -2
- package/build/lib/createInfiniteQuery.mjs.map +1 -1
- package/build/lib/createMutation.d.ts +2 -6
- package/build/lib/createMutation.esm.js +4 -4
- package/build/lib/createMutation.esm.js.map +1 -1
- package/build/lib/createMutation.js +3 -3
- package/build/lib/createMutation.js.map +1 -1
- package/build/lib/createMutation.mjs +4 -4
- package/build/lib/createMutation.mjs.map +1 -1
- package/build/lib/createQuery.d.ts +2 -6
- package/build/lib/createQuery.esm.js +2 -2
- package/build/lib/createQuery.esm.js.map +1 -1
- package/build/lib/createQuery.js +2 -2
- package/build/lib/createQuery.js.map +1 -1
- package/build/lib/createQuery.mjs +2 -2
- package/build/lib/createQuery.mjs.map +1 -1
- package/build/lib/createSuspenseInfiniteQuery.d.ts +2 -5
- package/build/lib/createSuspenseInfiniteQuery.esm.js +2 -2
- package/build/lib/createSuspenseInfiniteQuery.esm.js.map +1 -1
- package/build/lib/createSuspenseInfiniteQuery.js +2 -2
- package/build/lib/createSuspenseInfiniteQuery.js.map +1 -1
- package/build/lib/createSuspenseInfiniteQuery.mjs +2 -2
- package/build/lib/createSuspenseInfiniteQuery.mjs.map +1 -1
- package/build/lib/createSuspenseQuery.d.ts +2 -6
- package/build/lib/createSuspenseQuery.esm.js +2 -2
- package/build/lib/createSuspenseQuery.esm.js.map +1 -1
- package/build/lib/createSuspenseQuery.js +2 -2
- package/build/lib/createSuspenseQuery.js.map +1 -1
- package/build/lib/createSuspenseQuery.mjs +2 -2
- package/build/lib/createSuspenseQuery.mjs.map +1 -1
- package/build/lib/index.d.ts +2 -3
- package/build/lib/index.esm.js +1 -2
- package/build/lib/index.esm.js.map +1 -1
- package/build/lib/index.js +1 -3
- package/build/lib/index.js.map +1 -1
- package/build/lib/index.mjs +1 -2
- package/build/lib/index.mjs.map +1 -1
- package/build/lib/types.d.ts +51 -48
- package/build/lib/utils.d.ts +6 -7
- package/build/lib/utils.esm.js +14 -21
- package/build/lib/utils.esm.js.map +1 -1
- package/build/lib/utils.js +15 -23
- package/build/lib/utils.js.map +1 -1
- package/build/lib/utils.mjs +14 -21
- package/build/lib/utils.mjs.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats.json +91 -129
- package/build/umd/index.development.js +50 -78
- package/build/umd/index.development.js.map +1 -1
- package/build/umd/index.production.js +1 -1
- package/build/umd/index.production.js.map +1 -1
- package/package.json +3 -8
- package/src/createBaseQuery.ts +35 -51
- package/src/createInfiniteQuery.ts +3 -24
- package/src/createMutation.ts +5 -15
- package/src/createQuery.tsx +3 -22
- package/src/createSuspenseInfiniteQuery.ts +3 -32
- package/src/createSuspenseQuery.ts +4 -29
- package/src/index.ts +6 -5
- package/src/types.ts +240 -190
- package/src/utils.ts +23 -22
- package/build/lib/createImmutableQuery.d.ts +0 -6
- package/build/lib/createImmutableQuery.esm.js +0 -19
- package/build/lib/createImmutableQuery.esm.js.map +0 -1
- package/build/lib/createImmutableQuery.js +0 -23
- package/build/lib/createImmutableQuery.js.map +0 -1
- package/build/lib/createImmutableQuery.mjs +0 -19
- package/build/lib/createImmutableQuery.mjs.map +0 -1
- package/src/createImmutableQuery.tsx +0 -54
package/README.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
<div align="center">
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
<br />
|
|
4
|
+
<br />
|
|
5
|
+
|
|
6
|
+
<p align="center">
|
|
7
|
+
<a aria-label="NPM version" href="https://quaere-site.vercel.app">
|
|
8
|
+
<img alt="" src="./assets/logo.svg" height="40">
|
|
9
|
+
</a>
|
|
10
|
+
</p>
|
|
3
11
|
|
|
4
12
|
<p>🕊️ A toolkit for ReactQuery that make ReactQuery reusable and typesafe</p>
|
|
5
13
|
|
|
@@ -20,9 +28,9 @@
|
|
|
20
28
|
|
|
21
29
|
- Make `queryKey` strongly related with `queryFn`
|
|
22
30
|
- Manage `queryKey` in a type-safe way
|
|
23
|
-
- Generate a custom ReactQuery hook quickly
|
|
24
31
|
- Make `queryClient`'s operations clearly associated with custom ReactQuery hooks
|
|
25
32
|
- Set defaultOptions for custom ReactQuery hooks easier and clearer
|
|
33
|
+
- Middleware
|
|
26
34
|
|
|
27
35
|

|
|
28
36
|
|
|
@@ -38,7 +46,6 @@ English | [简体中文](./README-zh_CN.md)
|
|
|
38
46
|
- Usage
|
|
39
47
|
- [createQuery](#createquery)
|
|
40
48
|
- [createInfiniteQuery](#createinfinitequery)
|
|
41
|
-
- [createImmutableQuery](#createimmutablequery)
|
|
42
49
|
- [createSuspenseQuery](#createsuspensequery)
|
|
43
50
|
- [createSuspenseInfiniteQuery](#createsuspenseinfinitequery)
|
|
44
51
|
- [createMutation](#createmutation)
|
|
@@ -86,8 +93,6 @@ const usePost = createQuery<Response, Variables, Error>({
|
|
|
86
93
|
// primaryKey equals to '/posts'
|
|
87
94
|
return fetch(`${primaryKey}/${variables.id}`).then(res => res.json())
|
|
88
95
|
},
|
|
89
|
-
// if u only wanna fetch once
|
|
90
|
-
enabled: (data) => !data,
|
|
91
96
|
suspense: true,
|
|
92
97
|
// u can also pass middleware to cutomize this hook's behavior
|
|
93
98
|
use: [myMiddleware]
|
|
@@ -132,7 +137,7 @@ const data = await queryClient.fetchQuery(usePost.getFetchOptions(variables))
|
|
|
132
137
|
const queries = useQueries({
|
|
133
138
|
queries: [
|
|
134
139
|
usePost.getFetchOptions(variables),
|
|
135
|
-
|
|
140
|
+
useUser.getFetchOptions(),
|
|
136
141
|
],
|
|
137
142
|
})
|
|
138
143
|
|
|
@@ -147,10 +152,6 @@ Options
|
|
|
147
152
|
- `primaryKey: string`
|
|
148
153
|
- Required
|
|
149
154
|
- `primaryKey` will be the first element of the array of `queryKey`
|
|
150
|
-
- `enabled: boolean | ((data: TData, variables: TVariables) => boolean)`
|
|
151
|
-
- Optional
|
|
152
|
-
- Set this to `false` to disable this query from automatically running.
|
|
153
|
-
- If set to a function, the function will be executed with the latest data to compute the boolean
|
|
154
155
|
- `use: Middleware[]`
|
|
155
156
|
- Optional
|
|
156
157
|
- array of middleware functions [(details)](#middleware)
|
|
@@ -163,15 +164,6 @@ Expose Methods
|
|
|
163
164
|
- `queryFn: QueryFunction<TFnData, [primaryKey, TVariables]>`
|
|
164
165
|
- `queryKeyHashFn: (queryKey: [primaryKey, TVariables]) => string`
|
|
165
166
|
|
|
166
|
-
Returns
|
|
167
|
-
|
|
168
|
-
- `queryKey: [primaryKey, TVariables]`
|
|
169
|
-
- The query key of this custom query.
|
|
170
|
-
- `variables: TVariables`
|
|
171
|
-
- The variables of this custom query.
|
|
172
|
-
- `setData: (updater: Updater<TData>, options?: SetDataOptions) => TData | undefined`
|
|
173
|
-
- it's args similar with `queryClient.setQueryData` but without `queryKey`
|
|
174
|
-
|
|
175
167
|
## createInfiniteQuery
|
|
176
168
|
|
|
177
169
|
### Usage
|
|
@@ -232,7 +224,9 @@ export default function Page() {
|
|
|
232
224
|
export async function getStaticProps() {
|
|
233
225
|
const queryClient = new QueryClient()
|
|
234
226
|
|
|
235
|
-
await queryClient.prefetchInfiniteQuery(
|
|
227
|
+
await queryClient.prefetchInfiniteQuery(
|
|
228
|
+
useProjects.getFetchOptions(variables)
|
|
229
|
+
)
|
|
236
230
|
|
|
237
231
|
return {
|
|
238
232
|
props: {
|
|
@@ -242,10 +236,9 @@ export async function getStaticProps() {
|
|
|
242
236
|
}
|
|
243
237
|
|
|
244
238
|
// usage outside of react component
|
|
245
|
-
const data = await queryClient.fetchInfiniteQuery(
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
const data = await queryClient.fetchInfiniteQuery(useProjects.getFetchOptions(variables))
|
|
239
|
+
const data = await queryClient.fetchInfiniteQuery(
|
|
240
|
+
useProjects.getFetchOptions(variables)
|
|
241
|
+
)
|
|
249
242
|
```
|
|
250
243
|
|
|
251
244
|
### Additional API Reference
|
|
@@ -255,10 +248,6 @@ Options
|
|
|
255
248
|
- `primaryKey: string`
|
|
256
249
|
- Required
|
|
257
250
|
- `primaryKey` will be the first element of the arrary of `queryKey`
|
|
258
|
-
- `enabled: boolean | ((data: TData, variables: TVariables) => boolean)`
|
|
259
|
-
- Optional
|
|
260
|
-
- Set this to `false` to disable this query from automatically running.
|
|
261
|
-
- If set to a function, the function will be executed with the latest data to compute the boolean
|
|
262
251
|
- `use: Middleware[]`
|
|
263
252
|
- Optional
|
|
264
253
|
- array of middleware functions [(details)](#middleware)
|
|
@@ -271,39 +260,6 @@ Expose Methods
|
|
|
271
260
|
- `queryFn: QueryFunction<TFnData, [primaryKey, TVariables]>`
|
|
272
261
|
- `queryKeyHashFn: (queryKey: [primaryKey, TVariables]) => string`
|
|
273
262
|
|
|
274
|
-
Returns
|
|
275
|
-
|
|
276
|
-
- `queryKey: [primaryKey, TVariables]`
|
|
277
|
-
- The query key of this custom query.
|
|
278
|
-
- `variables: TVariables`
|
|
279
|
-
- The variables of this custom query.
|
|
280
|
-
- `setData: (updater: Updater<InfiniteData<TFnData>>, options?: SetDataOptions) => TData | undefined`
|
|
281
|
-
- it's args similar with `queryClient.setQueryData` but without `queryKey`
|
|
282
|
-
|
|
283
|
-
## createImmutableQuery
|
|
284
|
-
|
|
285
|
-
If the resource is immutable, no matter how many times we request it again, it will never change. In this case, we can disable all automatic re-requests for it.
|
|
286
|
-
ReactQueryKit provides a helper function `createImmutableQuery` to mark a resource as immutable.
|
|
287
|
-
|
|
288
|
-
```ts
|
|
289
|
-
import { createImmutableQuery } from 'react-query-kit'
|
|
290
|
-
|
|
291
|
-
createImmutableQuery({
|
|
292
|
-
...options,
|
|
293
|
-
})
|
|
294
|
-
|
|
295
|
-
// equals to
|
|
296
|
-
createQuery({
|
|
297
|
-
...options,
|
|
298
|
-
refetchInterval: false,
|
|
299
|
-
refetchOnMount: false,
|
|
300
|
-
refetchOnReconnect: false,
|
|
301
|
-
refetchOnWindowFocus: false,
|
|
302
|
-
staleTime: Infinity,
|
|
303
|
-
gcTime: Infinity,
|
|
304
|
-
})
|
|
305
|
-
```
|
|
306
|
-
|
|
307
263
|
## createSuspenseQuery
|
|
308
264
|
|
|
309
265
|
This has the same effect as setting the `suspense` option to `true` in the query config, but it works better in TypeScript, because `data` is guaranteed to be defined (as errors and loading states are handled by Suspense- and ErrorBoundaries).
|
|
@@ -422,16 +378,21 @@ Middleware receive the hook and can execute logic before and after running it. I
|
|
|
422
378
|
### Usage
|
|
423
379
|
|
|
424
380
|
```ts
|
|
425
|
-
import { Middleware, MutationHook, QueryHook } from 'react-query-kit'
|
|
381
|
+
import { Middleware, MutationHook, QueryHook, getKey } from 'react-query-kit'
|
|
426
382
|
|
|
427
383
|
const myMiddleware: Middleware<
|
|
428
384
|
QueryHook<Response, Variables>
|
|
429
385
|
> = useQueryNext => {
|
|
430
386
|
return options => {
|
|
431
387
|
const { userId } = useAuth()
|
|
388
|
+
const client = useQueryClient()
|
|
389
|
+
const variables = options.variables ?? { id: userId }
|
|
390
|
+
const hasData = () => !!client.getQueryData(useUser.getKey(variables))
|
|
391
|
+
|
|
432
392
|
return useQueryNext({
|
|
433
393
|
...options,
|
|
434
|
-
variables
|
|
394
|
+
variables,
|
|
395
|
+
enabled: options.enabled ?? !hasData(),
|
|
435
396
|
})
|
|
436
397
|
}
|
|
437
398
|
}
|
|
@@ -442,10 +403,16 @@ const useUser = createQuery<Response, Variables>({
|
|
|
442
403
|
})
|
|
443
404
|
|
|
444
405
|
// global middlewares
|
|
445
|
-
const
|
|
406
|
+
const disabledIfHasData: Middleware<QueryHook> = useQueryNext => {
|
|
446
407
|
return options => {
|
|
447
|
-
|
|
448
|
-
|
|
408
|
+
const client = useQueryClient()
|
|
409
|
+
const hasData = () =>
|
|
410
|
+
!!client.getQueryData(getKey(options.primaryKey, options.variables))
|
|
411
|
+
|
|
412
|
+
return useQueryNext({
|
|
413
|
+
...options,
|
|
414
|
+
enabled: options.enabled ?? !hasData(),
|
|
415
|
+
})
|
|
449
416
|
}
|
|
450
417
|
}
|
|
451
418
|
const mutationMiddleware: Middleware<MutationHook> = useMutationNext => {
|
|
@@ -457,7 +424,7 @@ const mutationMiddleware: Middleware<MutationHook> = useMutationNext => {
|
|
|
457
424
|
|
|
458
425
|
const queryClient = createQueryClient({
|
|
459
426
|
queries: {
|
|
460
|
-
use: [
|
|
427
|
+
use: [disabledIfHasData],
|
|
461
428
|
},
|
|
462
429
|
mutations: {
|
|
463
430
|
use: [mutationMiddleware],
|
|
@@ -487,14 +454,17 @@ exit a
|
|
|
487
454
|
|
|
488
455
|
## Type inference
|
|
489
456
|
|
|
490
|
-
You can extract the TypeScript type of any custom hook with `
|
|
457
|
+
You can extract the TypeScript type of any custom hook with `inferData` or `inferVariables`
|
|
491
458
|
|
|
492
459
|
```ts
|
|
493
|
-
import { inferData, inferFnData, inferVariables } from 'react-query-kit'
|
|
460
|
+
import { inferData, inferFnData, inferVariables, inferOptions } from 'react-query-kit'
|
|
461
|
+
|
|
462
|
+
const useProjects = createInfiniteQuery<Response, Variables>(...)
|
|
494
463
|
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
464
|
+
inferData<typeof useProjects> // InfiniteData<Response>
|
|
465
|
+
inferFnData<typeof useProjects> // Response
|
|
466
|
+
inferVariables<typeof useProjects> // Variables
|
|
467
|
+
inferOptions<typeof useProjects> // InfiniteQueryHookOptions<...>
|
|
498
468
|
```
|
|
499
469
|
|
|
500
470
|
## Issues
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { UseBaseQueryOptions } from '@tanstack/react-query';
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
type QueryBaseHookOptions = Omit<UseBaseQueryOptions, 'queryKey' | 'queryFn'> & {
|
|
3
|
+
variables?: any;
|
|
4
|
+
};
|
|
4
5
|
export declare function createBaseQuery(defaultOptions: any, useRQHook: (options: any, queryClient?: any) => any, overrideOptions?: QueryBaseHookOptions): any;
|
|
5
6
|
export {};
|
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { withMiddleware, getKey } from './utils.esm.js';
|
|
2
2
|
|
|
3
3
|
function createBaseQuery(defaultOptions, useRQHook, overrideOptions) {
|
|
4
4
|
const {
|
|
5
|
-
primaryKey
|
|
5
|
+
primaryKey,
|
|
6
|
+
queryFn,
|
|
7
|
+
queryKeyHashFn,
|
|
8
|
+
getPreviousPageParam,
|
|
9
|
+
getNextPageParam,
|
|
10
|
+
initialPageParam
|
|
6
11
|
} = defaultOptions;
|
|
7
12
|
|
|
8
13
|
if (process.env.NODE_ENV !== 'production') {
|
|
@@ -14,45 +19,34 @@ function createBaseQuery(defaultOptions, useRQHook, overrideOptions) {
|
|
|
14
19
|
|
|
15
20
|
const getPrimaryKey = () => primaryKey;
|
|
16
21
|
|
|
17
|
-
const getKey = variables =>
|
|
22
|
+
const getKey$1 = variables => getKey(primaryKey, variables);
|
|
18
23
|
|
|
19
24
|
const getFetchOptions = variables => {
|
|
20
25
|
return {
|
|
21
|
-
queryKey: getKey(variables),
|
|
22
|
-
queryFn
|
|
23
|
-
queryKeyHashFn
|
|
24
|
-
getPreviousPageParam
|
|
25
|
-
getNextPageParam
|
|
26
|
-
initialPageParam
|
|
26
|
+
queryKey: getKey$1(variables),
|
|
27
|
+
queryFn,
|
|
28
|
+
queryKeyHashFn,
|
|
29
|
+
getPreviousPageParam,
|
|
30
|
+
getNextPageParam,
|
|
31
|
+
initialPageParam
|
|
27
32
|
};
|
|
28
33
|
};
|
|
29
34
|
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
...
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
};
|
|
39
|
-
const queryKey = getKey(variables);
|
|
40
|
-
const result = useRQHook({ ...mergedOptions,
|
|
41
|
-
enabled: typeof enabled === 'function' ? enabled(client.getQueryData(queryKey), variables) : enabled,
|
|
42
|
-
queryKey
|
|
43
|
-
}, client);
|
|
44
|
-
return Object.assign(result, {
|
|
45
|
-
queryKey: queryKey,
|
|
46
|
-
variables,
|
|
47
|
-
setData: (updater, setDataOptions) => client.setQueryData(queryKey, updater, setDataOptions)
|
|
48
|
-
});
|
|
35
|
+
const useBaseHook = ({
|
|
36
|
+
variables,
|
|
37
|
+
...rest
|
|
38
|
+
}, queryClient) => {
|
|
39
|
+
return useRQHook({ ...rest,
|
|
40
|
+
...overrideOptions,
|
|
41
|
+
queryKey: getKey$1(variables)
|
|
42
|
+
}, queryClient);
|
|
49
43
|
};
|
|
50
44
|
|
|
51
|
-
return Object.assign(
|
|
45
|
+
return Object.assign(withMiddleware(useBaseHook, defaultOptions, 'queries'), {
|
|
52
46
|
getPrimaryKey,
|
|
53
|
-
getKey,
|
|
54
|
-
queryFn
|
|
55
|
-
queryKeyHashFn
|
|
47
|
+
getKey: getKey$1,
|
|
48
|
+
queryFn,
|
|
49
|
+
queryKeyHashFn,
|
|
56
50
|
getFetchOptions
|
|
57
51
|
});
|
|
58
52
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createBaseQuery.esm.js","sources":["../../src/createBaseQuery.ts"],"sourcesContent":["import type {\n QueryClient,\n
|
|
1
|
+
{"version":3,"file":"createBaseQuery.esm.js","sources":["../../src/createBaseQuery.ts"],"sourcesContent":["import type {\n QueryClient,\n UseBaseQueryOptions,\n UseInfiniteQueryOptions,\n} from '@tanstack/react-query'\n\nimport type {\n AdditionalCreateOptions,\n CompatibleWithV4,\n Middleware,\n} from './types'\nimport { getKey as getQueryKey, withMiddleware } from './utils'\n\ninterface CreateBaseQueryOptions\n extends Omit<UseInfiniteQueryOptions, 'queryKey' | 'queryFn'>,\n AdditionalCreateOptions<any, any> {\n use?: Middleware[]\n}\n\ntype QueryBaseHookOptions = Omit<\n UseBaseQueryOptions,\n 'queryKey' | 'queryFn'\n> & {\n variables?: any\n}\n\nexport function createBaseQuery(\n defaultOptions: any,\n useRQHook: (options: any, queryClient?: any) => any,\n overrideOptions?: QueryBaseHookOptions\n): any {\n const {\n primaryKey,\n queryFn,\n queryKeyHashFn,\n getPreviousPageParam,\n getNextPageParam,\n initialPageParam,\n } = defaultOptions as CreateBaseQueryOptions\n\n if (process.env.NODE_ENV !== 'production') {\n // @ts-ignore\n if (defaultOptions.useDefaultOptions) {\n throw new Error(\n 'useDefaultOptions is not supported, please use middleware instead.'\n )\n }\n }\n\n const getPrimaryKey = () => primaryKey\n\n const getKey = (variables?: any) => getQueryKey(primaryKey, variables)\n\n const getFetchOptions = (variables: any) => {\n return {\n queryKey: getKey(variables),\n queryFn,\n queryKeyHashFn,\n getPreviousPageParam,\n getNextPageParam,\n initialPageParam,\n }\n }\n\n const useBaseHook = (\n { variables, ...rest }: QueryBaseHookOptions,\n queryClient?: CompatibleWithV4<QueryClient, void>\n ) => {\n return useRQHook(\n {\n ...rest,\n ...overrideOptions,\n queryKey: getKey(variables),\n },\n queryClient\n )\n }\n\n return Object.assign(withMiddleware(useBaseHook, defaultOptions, 'queries'), {\n getPrimaryKey,\n getKey,\n queryFn,\n queryKeyHashFn,\n getFetchOptions,\n })\n}\n"],"names":["createBaseQuery","defaultOptions","useRQHook","overrideOptions","primaryKey","queryFn","queryKeyHashFn","getPreviousPageParam","getNextPageParam","initialPageParam","process","env","NODE_ENV","useDefaultOptions","Error","getPrimaryKey","getKey","variables","getQueryKey","getFetchOptions","queryKey","useBaseHook","rest","queryClient","Object","assign","withMiddleware"],"mappings":";;AA0BO,SAASA,eAAT,CACLC,cADK,EAELC,SAFK,EAGLC,eAHK,EAIA;EACL,MAAM;IACJC,UADI;IAEJC,OAFI;IAGJC,cAHI;IAIJC,oBAJI;IAKJC,gBALI;AAMJC,IAAAA,gBAAAA;AANI,GAAA,GAOFR,cAPJ,CAAA;;AASA,EAAA,IAAIS,OAAO,CAACC,GAAR,CAAYC,QAAZ,KAAyB,YAA7B,EAA2C;AACzC;IACA,IAAIX,cAAc,CAACY,iBAAnB,EAAsC;AACpC,MAAA,MAAM,IAAIC,KAAJ,CACJ,oEADI,CAAN,CAAA;AAGD,KAAA;AACF,GAAA;;EAED,MAAMC,aAAa,GAAG,MAAMX,UAA5B,CAAA;;EAEA,MAAMY,QAAM,GAAIC,SAAD,IAAqBC,MAAW,CAACd,UAAD,EAAaa,SAAb,CAA/C,CAAA;;EAEA,MAAME,eAAe,GAAIF,SAAD,IAAoB;IAC1C,OAAO;AACLG,MAAAA,QAAQ,EAAEJ,QAAM,CAACC,SAAD,CADX;MAELZ,OAFK;MAGLC,cAHK;MAILC,oBAJK;MAKLC,gBALK;AAMLC,MAAAA,gBAAAA;KANF,CAAA;GADF,CAAA;;EAWA,MAAMY,WAAW,GAAG,CAClB;IAAEJ,SAAF;IAAa,GAAGK,IAAAA;GADE,EAElBC,WAFkB,KAGf;AACH,IAAA,OAAOrB,SAAS,CACd,EACE,GAAGoB,IADL;AAEE,MAAA,GAAGnB,eAFL;MAGEiB,QAAQ,EAAEJ,QAAM,CAACC,SAAD,CAAA;KAJJ,EAMdM,WANc,CAAhB,CAAA;GAJF,CAAA;;AAcA,EAAA,OAAOC,MAAM,CAACC,MAAP,CAAcC,cAAc,CAACL,WAAD,EAAcpB,cAAd,EAA8B,SAA9B,CAA5B,EAAsE;IAC3Ec,aAD2E;YAE3EC,QAF2E;IAG3EX,OAH2E;IAI3EC,cAJ2E;AAK3Ea,IAAAA,eAAAA;AAL2E,GAAtE,CAAP,CAAA;AAOD;;;;"}
|
|
@@ -6,7 +6,12 @@ var utils = require('./utils.js');
|
|
|
6
6
|
|
|
7
7
|
function createBaseQuery(defaultOptions, useRQHook, overrideOptions) {
|
|
8
8
|
const {
|
|
9
|
-
primaryKey
|
|
9
|
+
primaryKey,
|
|
10
|
+
queryFn,
|
|
11
|
+
queryKeyHashFn,
|
|
12
|
+
getPreviousPageParam,
|
|
13
|
+
getNextPageParam,
|
|
14
|
+
initialPageParam
|
|
10
15
|
} = defaultOptions;
|
|
11
16
|
|
|
12
17
|
if (process.env.NODE_ENV !== 'production') {
|
|
@@ -18,45 +23,34 @@ function createBaseQuery(defaultOptions, useRQHook, overrideOptions) {
|
|
|
18
23
|
|
|
19
24
|
const getPrimaryKey = () => primaryKey;
|
|
20
25
|
|
|
21
|
-
const getKey = variables => utils.
|
|
26
|
+
const getKey = variables => utils.getKey(primaryKey, variables);
|
|
22
27
|
|
|
23
28
|
const getFetchOptions = variables => {
|
|
24
29
|
return {
|
|
25
30
|
queryKey: getKey(variables),
|
|
26
|
-
queryFn
|
|
27
|
-
queryKeyHashFn
|
|
28
|
-
getPreviousPageParam
|
|
29
|
-
getNextPageParam
|
|
30
|
-
initialPageParam
|
|
31
|
+
queryFn,
|
|
32
|
+
queryKeyHashFn,
|
|
33
|
+
getPreviousPageParam,
|
|
34
|
+
getNextPageParam,
|
|
35
|
+
initialPageParam
|
|
31
36
|
};
|
|
32
37
|
};
|
|
33
38
|
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
...
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
};
|
|
43
|
-
const queryKey = getKey(variables);
|
|
44
|
-
const result = useRQHook({ ...mergedOptions,
|
|
45
|
-
enabled: typeof enabled === 'function' ? enabled(client.getQueryData(queryKey), variables) : enabled,
|
|
46
|
-
queryKey
|
|
47
|
-
}, client);
|
|
48
|
-
return Object.assign(result, {
|
|
49
|
-
queryKey: queryKey,
|
|
50
|
-
variables,
|
|
51
|
-
setData: (updater, setDataOptions) => client.setQueryData(queryKey, updater, setDataOptions)
|
|
52
|
-
});
|
|
39
|
+
const useBaseHook = ({
|
|
40
|
+
variables,
|
|
41
|
+
...rest
|
|
42
|
+
}, queryClient) => {
|
|
43
|
+
return useRQHook({ ...rest,
|
|
44
|
+
...overrideOptions,
|
|
45
|
+
queryKey: getKey(variables)
|
|
46
|
+
}, queryClient);
|
|
53
47
|
};
|
|
54
48
|
|
|
55
|
-
return Object.assign(utils.
|
|
49
|
+
return Object.assign(utils.withMiddleware(useBaseHook, defaultOptions, 'queries'), {
|
|
56
50
|
getPrimaryKey,
|
|
57
51
|
getKey,
|
|
58
|
-
queryFn
|
|
59
|
-
queryKeyHashFn
|
|
52
|
+
queryFn,
|
|
53
|
+
queryKeyHashFn,
|
|
60
54
|
getFetchOptions
|
|
61
55
|
});
|
|
62
56
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createBaseQuery.js","sources":["../../src/createBaseQuery.ts"],"sourcesContent":["import type {\n QueryClient,\n
|
|
1
|
+
{"version":3,"file":"createBaseQuery.js","sources":["../../src/createBaseQuery.ts"],"sourcesContent":["import type {\n QueryClient,\n UseBaseQueryOptions,\n UseInfiniteQueryOptions,\n} from '@tanstack/react-query'\n\nimport type {\n AdditionalCreateOptions,\n CompatibleWithV4,\n Middleware,\n} from './types'\nimport { getKey as getQueryKey, withMiddleware } from './utils'\n\ninterface CreateBaseQueryOptions\n extends Omit<UseInfiniteQueryOptions, 'queryKey' | 'queryFn'>,\n AdditionalCreateOptions<any, any> {\n use?: Middleware[]\n}\n\ntype QueryBaseHookOptions = Omit<\n UseBaseQueryOptions,\n 'queryKey' | 'queryFn'\n> & {\n variables?: any\n}\n\nexport function createBaseQuery(\n defaultOptions: any,\n useRQHook: (options: any, queryClient?: any) => any,\n overrideOptions?: QueryBaseHookOptions\n): any {\n const {\n primaryKey,\n queryFn,\n queryKeyHashFn,\n getPreviousPageParam,\n getNextPageParam,\n initialPageParam,\n } = defaultOptions as CreateBaseQueryOptions\n\n if (process.env.NODE_ENV !== 'production') {\n // @ts-ignore\n if (defaultOptions.useDefaultOptions) {\n throw new Error(\n 'useDefaultOptions is not supported, please use middleware instead.'\n )\n }\n }\n\n const getPrimaryKey = () => primaryKey\n\n const getKey = (variables?: any) => getQueryKey(primaryKey, variables)\n\n const getFetchOptions = (variables: any) => {\n return {\n queryKey: getKey(variables),\n queryFn,\n queryKeyHashFn,\n getPreviousPageParam,\n getNextPageParam,\n initialPageParam,\n }\n }\n\n const useBaseHook = (\n { variables, ...rest }: QueryBaseHookOptions,\n queryClient?: CompatibleWithV4<QueryClient, void>\n ) => {\n return useRQHook(\n {\n ...rest,\n ...overrideOptions,\n queryKey: getKey(variables),\n },\n queryClient\n )\n }\n\n return Object.assign(withMiddleware(useBaseHook, defaultOptions, 'queries'), {\n getPrimaryKey,\n getKey,\n queryFn,\n queryKeyHashFn,\n getFetchOptions,\n })\n}\n"],"names":["createBaseQuery","defaultOptions","useRQHook","overrideOptions","primaryKey","queryFn","queryKeyHashFn","getPreviousPageParam","getNextPageParam","initialPageParam","process","env","NODE_ENV","useDefaultOptions","Error","getPrimaryKey","getKey","variables","getQueryKey","getFetchOptions","queryKey","useBaseHook","rest","queryClient","Object","assign","withMiddleware"],"mappings":";;;;;;AA0BO,SAASA,eAAT,CACLC,cADK,EAELC,SAFK,EAGLC,eAHK,EAIA;EACL,MAAM;IACJC,UADI;IAEJC,OAFI;IAGJC,cAHI;IAIJC,oBAJI;IAKJC,gBALI;AAMJC,IAAAA,gBAAAA;AANI,GAAA,GAOFR,cAPJ,CAAA;;AASA,EAAA,IAAIS,OAAO,CAACC,GAAR,CAAYC,QAAZ,KAAyB,YAA7B,EAA2C;AACzC;IACA,IAAIX,cAAc,CAACY,iBAAnB,EAAsC;AACpC,MAAA,MAAM,IAAIC,KAAJ,CACJ,oEADI,CAAN,CAAA;AAGD,KAAA;AACF,GAAA;;EAED,MAAMC,aAAa,GAAG,MAAMX,UAA5B,CAAA;;EAEA,MAAMY,MAAM,GAAIC,SAAD,IAAqBC,YAAW,CAACd,UAAD,EAAaa,SAAb,CAA/C,CAAA;;EAEA,MAAME,eAAe,GAAIF,SAAD,IAAoB;IAC1C,OAAO;AACLG,MAAAA,QAAQ,EAAEJ,MAAM,CAACC,SAAD,CADX;MAELZ,OAFK;MAGLC,cAHK;MAILC,oBAJK;MAKLC,gBALK;AAMLC,MAAAA,gBAAAA;KANF,CAAA;GADF,CAAA;;EAWA,MAAMY,WAAW,GAAG,CAClB;IAAEJ,SAAF;IAAa,GAAGK,IAAAA;GADE,EAElBC,WAFkB,KAGf;AACH,IAAA,OAAOrB,SAAS,CACd,EACE,GAAGoB,IADL;AAEE,MAAA,GAAGnB,eAFL;MAGEiB,QAAQ,EAAEJ,MAAM,CAACC,SAAD,CAAA;KAJJ,EAMdM,WANc,CAAhB,CAAA;GAJF,CAAA;;AAcA,EAAA,OAAOC,MAAM,CAACC,MAAP,CAAcC,oBAAc,CAACL,WAAD,EAAcpB,cAAd,EAA8B,SAA9B,CAA5B,EAAsE;IAC3Ec,aAD2E;IAE3EC,MAF2E;IAG3EX,OAH2E;IAI3EC,cAJ2E;AAK3Ea,IAAAA,eAAAA;AAL2E,GAAtE,CAAP,CAAA;AAOD;;;;"}
|
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { withMiddleware, getKey } from './utils.mjs';
|
|
2
2
|
|
|
3
3
|
function createBaseQuery(defaultOptions, useRQHook, overrideOptions) {
|
|
4
4
|
const {
|
|
5
|
-
primaryKey
|
|
5
|
+
primaryKey,
|
|
6
|
+
queryFn,
|
|
7
|
+
queryKeyHashFn,
|
|
8
|
+
getPreviousPageParam,
|
|
9
|
+
getNextPageParam,
|
|
10
|
+
initialPageParam
|
|
6
11
|
} = defaultOptions;
|
|
7
12
|
|
|
8
13
|
if (process.env.NODE_ENV !== 'production') {
|
|
@@ -14,45 +19,34 @@ function createBaseQuery(defaultOptions, useRQHook, overrideOptions) {
|
|
|
14
19
|
|
|
15
20
|
const getPrimaryKey = () => primaryKey;
|
|
16
21
|
|
|
17
|
-
const getKey = variables =>
|
|
22
|
+
const getKey$1 = variables => getKey(primaryKey, variables);
|
|
18
23
|
|
|
19
24
|
const getFetchOptions = variables => {
|
|
20
25
|
return {
|
|
21
|
-
queryKey: getKey(variables),
|
|
22
|
-
queryFn
|
|
23
|
-
queryKeyHashFn
|
|
24
|
-
getPreviousPageParam
|
|
25
|
-
getNextPageParam
|
|
26
|
-
initialPageParam
|
|
26
|
+
queryKey: getKey$1(variables),
|
|
27
|
+
queryFn,
|
|
28
|
+
queryKeyHashFn,
|
|
29
|
+
getPreviousPageParam,
|
|
30
|
+
getNextPageParam,
|
|
31
|
+
initialPageParam
|
|
27
32
|
};
|
|
28
33
|
};
|
|
29
34
|
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
...
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
};
|
|
39
|
-
const queryKey = getKey(variables);
|
|
40
|
-
const result = useRQHook({ ...mergedOptions,
|
|
41
|
-
enabled: typeof enabled === 'function' ? enabled(client.getQueryData(queryKey), variables) : enabled,
|
|
42
|
-
queryKey
|
|
43
|
-
}, client);
|
|
44
|
-
return Object.assign(result, {
|
|
45
|
-
queryKey: queryKey,
|
|
46
|
-
variables,
|
|
47
|
-
setData: (updater, setDataOptions) => client.setQueryData(queryKey, updater, setDataOptions)
|
|
48
|
-
});
|
|
35
|
+
const useBaseHook = ({
|
|
36
|
+
variables,
|
|
37
|
+
...rest
|
|
38
|
+
}, queryClient) => {
|
|
39
|
+
return useRQHook({ ...rest,
|
|
40
|
+
...overrideOptions,
|
|
41
|
+
queryKey: getKey$1(variables)
|
|
42
|
+
}, queryClient);
|
|
49
43
|
};
|
|
50
44
|
|
|
51
|
-
return Object.assign(
|
|
45
|
+
return Object.assign(withMiddleware(useBaseHook, defaultOptions, 'queries'), {
|
|
52
46
|
getPrimaryKey,
|
|
53
|
-
getKey,
|
|
54
|
-
queryFn
|
|
55
|
-
queryKeyHashFn
|
|
47
|
+
getKey: getKey$1,
|
|
48
|
+
queryFn,
|
|
49
|
+
queryKeyHashFn,
|
|
56
50
|
getFetchOptions
|
|
57
51
|
});
|
|
58
52
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createBaseQuery.mjs","sources":["../../src/createBaseQuery.ts"],"sourcesContent":["import type {\n QueryClient,\n
|
|
1
|
+
{"version":3,"file":"createBaseQuery.mjs","sources":["../../src/createBaseQuery.ts"],"sourcesContent":["import type {\n QueryClient,\n UseBaseQueryOptions,\n UseInfiniteQueryOptions,\n} from '@tanstack/react-query'\n\nimport type {\n AdditionalCreateOptions,\n CompatibleWithV4,\n Middleware,\n} from './types'\nimport { getKey as getQueryKey, withMiddleware } from './utils'\n\ninterface CreateBaseQueryOptions\n extends Omit<UseInfiniteQueryOptions, 'queryKey' | 'queryFn'>,\n AdditionalCreateOptions<any, any> {\n use?: Middleware[]\n}\n\ntype QueryBaseHookOptions = Omit<\n UseBaseQueryOptions,\n 'queryKey' | 'queryFn'\n> & {\n variables?: any\n}\n\nexport function createBaseQuery(\n defaultOptions: any,\n useRQHook: (options: any, queryClient?: any) => any,\n overrideOptions?: QueryBaseHookOptions\n): any {\n const {\n primaryKey,\n queryFn,\n queryKeyHashFn,\n getPreviousPageParam,\n getNextPageParam,\n initialPageParam,\n } = defaultOptions as CreateBaseQueryOptions\n\n if (process.env.NODE_ENV !== 'production') {\n // @ts-ignore\n if (defaultOptions.useDefaultOptions) {\n throw new Error(\n 'useDefaultOptions is not supported, please use middleware instead.'\n )\n }\n }\n\n const getPrimaryKey = () => primaryKey\n\n const getKey = (variables?: any) => getQueryKey(primaryKey, variables)\n\n const getFetchOptions = (variables: any) => {\n return {\n queryKey: getKey(variables),\n queryFn,\n queryKeyHashFn,\n getPreviousPageParam,\n getNextPageParam,\n initialPageParam,\n }\n }\n\n const useBaseHook = (\n { variables, ...rest }: QueryBaseHookOptions,\n queryClient?: CompatibleWithV4<QueryClient, void>\n ) => {\n return useRQHook(\n {\n ...rest,\n ...overrideOptions,\n queryKey: getKey(variables),\n },\n queryClient\n )\n }\n\n return Object.assign(withMiddleware(useBaseHook, defaultOptions, 'queries'), {\n getPrimaryKey,\n getKey,\n queryFn,\n queryKeyHashFn,\n getFetchOptions,\n })\n}\n"],"names":["createBaseQuery","defaultOptions","useRQHook","overrideOptions","primaryKey","queryFn","queryKeyHashFn","getPreviousPageParam","getNextPageParam","initialPageParam","process","env","NODE_ENV","useDefaultOptions","Error","getPrimaryKey","getKey","variables","getQueryKey","getFetchOptions","queryKey","useBaseHook","rest","queryClient","Object","assign","withMiddleware"],"mappings":";;AA0BO,SAASA,eAAT,CACLC,cADK,EAELC,SAFK,EAGLC,eAHK,EAIA;EACL,MAAM;IACJC,UADI;IAEJC,OAFI;IAGJC,cAHI;IAIJC,oBAJI;IAKJC,gBALI;AAMJC,IAAAA,gBAAAA;AANI,GAAA,GAOFR,cAPJ,CAAA;;AASA,EAAA,IAAIS,OAAO,CAACC,GAAR,CAAYC,QAAZ,KAAyB,YAA7B,EAA2C;AACzC;IACA,IAAIX,cAAc,CAACY,iBAAnB,EAAsC;AACpC,MAAA,MAAM,IAAIC,KAAJ,CACJ,oEADI,CAAN,CAAA;AAGD,KAAA;AACF,GAAA;;EAED,MAAMC,aAAa,GAAG,MAAMX,UAA5B,CAAA;;EAEA,MAAMY,QAAM,GAAIC,SAAD,IAAqBC,MAAW,CAACd,UAAD,EAAaa,SAAb,CAA/C,CAAA;;EAEA,MAAME,eAAe,GAAIF,SAAD,IAAoB;IAC1C,OAAO;AACLG,MAAAA,QAAQ,EAAEJ,QAAM,CAACC,SAAD,CADX;MAELZ,OAFK;MAGLC,cAHK;MAILC,oBAJK;MAKLC,gBALK;AAMLC,MAAAA,gBAAAA;KANF,CAAA;GADF,CAAA;;EAWA,MAAMY,WAAW,GAAG,CAClB;IAAEJ,SAAF;IAAa,GAAGK,IAAAA;GADE,EAElBC,WAFkB,KAGf;AACH,IAAA,OAAOrB,SAAS,CACd,EACE,GAAGoB,IADL;AAEE,MAAA,GAAGnB,eAFL;MAGEiB,QAAQ,EAAEJ,QAAM,CAACC,SAAD,CAAA;KAJJ,EAMdM,WANc,CAAhB,CAAA;GAJF,CAAA;;AAcA,EAAA,OAAOC,MAAM,CAACC,MAAP,CAAcC,cAAc,CAACL,WAAD,EAAcpB,cAAd,EAA8B,SAA9B,CAA5B,EAAsE;IAC3Ec,aAD2E;YAE3EC,QAF2E;IAG3EX,OAH2E;IAI3EC,cAJ2E;AAK3Ea,IAAAA,eAAAA;AAL2E,GAAtE,CAAP,CAAA;AAOD;;;;"}
|
|
@@ -1,5 +1,2 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export
|
|
3
|
-
use?: Middleware<InfiniteQueryHook<TFnData, TVariables, TError, TPageParam>>[];
|
|
4
|
-
}
|
|
5
|
-
export declare function createInfiniteQuery<TFnData, TVariables = any, TError = DefaultError, TPageParam = number>(options: CreateInfiniteQueryOptions<TFnData, TVariables, TError, TPageParam>): InfiniteQueryHook<TFnData, TVariables, TError, TPageParam>;
|
|
1
|
+
import type { CreateInfiniteQueryOptions, InfiniteQueryHook } from './types';
|
|
2
|
+
export declare const createInfiniteQuery: <TFnData, TVariables = any, TError = Error, TPageParam = number>(options: CreateInfiniteQueryOptions<TFnData, TVariables, TError, TPageParam>) => InfiniteQueryHook<TFnData, TVariables, TError, TPageParam>;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { useInfiniteQuery } from '@tanstack/react-query';
|
|
2
2
|
import { createBaseQuery } from './createBaseQuery.esm.js';
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
const createInfiniteQuery = options => {
|
|
5
5
|
return createBaseQuery(options, useInfiniteQuery);
|
|
6
|
-
}
|
|
6
|
+
};
|
|
7
7
|
|
|
8
8
|
export { createInfiniteQuery };
|
|
9
9
|
//# sourceMappingURL=createInfiniteQuery.esm.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createInfiniteQuery.esm.js","sources":["../../src/createInfiniteQuery.ts"],"sourcesContent":["import { useInfiniteQuery } from '@tanstack/react-query'\n\nimport { createBaseQuery } from './createBaseQuery'\nimport type {\n
|
|
1
|
+
{"version":3,"file":"createInfiniteQuery.esm.js","sources":["../../src/createInfiniteQuery.ts"],"sourcesContent":["import { useInfiniteQuery } from '@tanstack/react-query'\n\nimport { createBaseQuery } from './createBaseQuery'\nimport type {\n CreateInfiniteQueryOptions,\n DefaultError,\n InfiniteQueryHook,\n} from './types'\n\nexport const createInfiniteQuery = <\n TFnData,\n TVariables = any,\n TError = DefaultError,\n TPageParam = number\n>(\n options: CreateInfiniteQueryOptions<TFnData, TVariables, TError, TPageParam>\n): InfiniteQueryHook<TFnData, TVariables, TError, TPageParam> => {\n return createBaseQuery(options, useInfiniteQuery)\n}\n"],"names":["createInfiniteQuery","options","createBaseQuery","useInfiniteQuery"],"mappings":";;;AASaA,MAAAA,mBAAmB,GAM9BC,OANiC,IAO8B;AAC/D,EAAA,OAAOC,eAAe,CAACD,OAAD,EAAUE,gBAAV,CAAtB,CAAA;AACD;;;;"}
|
|
@@ -5,9 +5,9 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var reactQuery = require('@tanstack/react-query');
|
|
6
6
|
var createBaseQuery = require('./createBaseQuery.js');
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
const createInfiniteQuery = options => {
|
|
9
9
|
return createBaseQuery.createBaseQuery(options, reactQuery.useInfiniteQuery);
|
|
10
|
-
}
|
|
10
|
+
};
|
|
11
11
|
|
|
12
12
|
exports.createInfiniteQuery = createInfiniteQuery;
|
|
13
13
|
//# sourceMappingURL=createInfiniteQuery.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createInfiniteQuery.js","sources":["../../src/createInfiniteQuery.ts"],"sourcesContent":["import { useInfiniteQuery } from '@tanstack/react-query'\n\nimport { createBaseQuery } from './createBaseQuery'\nimport type {\n
|
|
1
|
+
{"version":3,"file":"createInfiniteQuery.js","sources":["../../src/createInfiniteQuery.ts"],"sourcesContent":["import { useInfiniteQuery } from '@tanstack/react-query'\n\nimport { createBaseQuery } from './createBaseQuery'\nimport type {\n CreateInfiniteQueryOptions,\n DefaultError,\n InfiniteQueryHook,\n} from './types'\n\nexport const createInfiniteQuery = <\n TFnData,\n TVariables = any,\n TError = DefaultError,\n TPageParam = number\n>(\n options: CreateInfiniteQueryOptions<TFnData, TVariables, TError, TPageParam>\n): InfiniteQueryHook<TFnData, TVariables, TError, TPageParam> => {\n return createBaseQuery(options, useInfiniteQuery)\n}\n"],"names":["createInfiniteQuery","options","createBaseQuery","useInfiniteQuery"],"mappings":";;;;;;;AASaA,MAAAA,mBAAmB,GAM9BC,OANiC,IAO8B;AAC/D,EAAA,OAAOC,+BAAe,CAACD,OAAD,EAAUE,2BAAV,CAAtB,CAAA;AACD;;;;"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { useInfiniteQuery } from '@tanstack/react-query';
|
|
2
2
|
import { createBaseQuery } from './createBaseQuery.mjs';
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
const createInfiniteQuery = options => {
|
|
5
5
|
return createBaseQuery(options, useInfiniteQuery);
|
|
6
|
-
}
|
|
6
|
+
};
|
|
7
7
|
|
|
8
8
|
export { createInfiniteQuery };
|
|
9
9
|
//# sourceMappingURL=createInfiniteQuery.mjs.map
|