react-query-kit 2.0.9 → 3.0.0-beta.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 +105 -48
- package/build/lib/createBaseQuery.d.ts +2 -6
- package/build/lib/createBaseQuery.esm.js +19 -12
- package/build/lib/createBaseQuery.esm.js.map +1 -1
- package/build/lib/createBaseQuery.js +19 -12
- package/build/lib/createBaseQuery.js.map +1 -1
- package/build/lib/createBaseQuery.mjs +19 -12
- package/build/lib/createBaseQuery.mjs.map +1 -1
- package/build/lib/createMutation.d.ts +1 -1
- package/build/lib/createMutation.esm.js +2 -3
- package/build/lib/createMutation.esm.js.map +1 -1
- package/build/lib/createMutation.js +2 -3
- package/build/lib/createMutation.js.map +1 -1
- package/build/lib/createMutation.mjs +2 -3
- package/build/lib/createMutation.mjs.map +1 -1
- package/build/lib/createQuery.esm.js.map +1 -1
- package/build/lib/createQuery.js.map +1 -1
- package/build/lib/createQuery.mjs.map +1 -1
- package/build/lib/createSuspenseInfiniteQuery.esm.js +1 -1
- package/build/lib/createSuspenseInfiniteQuery.esm.js.map +1 -1
- package/build/lib/createSuspenseInfiniteQuery.js +1 -1
- package/build/lib/createSuspenseInfiniteQuery.js.map +1 -1
- package/build/lib/createSuspenseInfiniteQuery.mjs +1 -1
- package/build/lib/createSuspenseInfiniteQuery.mjs.map +1 -1
- package/build/lib/createSuspenseQuery.esm.js +1 -1
- package/build/lib/createSuspenseQuery.esm.js.map +1 -1
- package/build/lib/createSuspenseQuery.js +1 -1
- package/build/lib/createSuspenseQuery.js.map +1 -1
- package/build/lib/createSuspenseQuery.mjs +1 -1
- package/build/lib/createSuspenseQuery.mjs.map +1 -1
- package/build/lib/types.d.ts +35 -50
- package/build/lib/utils.d.ts +9 -8
- package/build/lib/utils.esm.js +10 -10
- package/build/lib/utils.esm.js.map +1 -1
- package/build/lib/utils.js +10 -10
- package/build/lib/utils.js.map +1 -1
- package/build/lib/utils.mjs +10 -10
- package/build/lib/utils.mjs.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats.json +96 -96
- package/build/umd/index.development.js +33 -27
- 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/build/zip/zip.esm.js +1 -1
- package/package.json +1 -1
- package/src/createBaseQuery.ts +25 -14
- package/src/createMutation.ts +4 -5
- package/src/createSuspenseInfiniteQuery.ts +1 -1
- package/src/createSuspenseQuery.ts +1 -1
- package/src/types.ts +96 -168
- package/src/utils.ts +17 -21
- /package/src/{createQuery.tsx → createQuery.ts} +0 -0
package/build/stats.json
CHANGED
|
@@ -10,35 +10,35 @@
|
|
|
10
10
|
"name": "src",
|
|
11
11
|
"children": [
|
|
12
12
|
{
|
|
13
|
-
"uid": "
|
|
13
|
+
"uid": "c574-19",
|
|
14
14
|
"name": "utils.ts"
|
|
15
15
|
},
|
|
16
16
|
{
|
|
17
|
-
"uid": "
|
|
17
|
+
"uid": "c574-21",
|
|
18
18
|
"name": "createBaseQuery.ts"
|
|
19
19
|
},
|
|
20
20
|
{
|
|
21
|
-
"uid": "
|
|
22
|
-
"name": "createQuery.
|
|
21
|
+
"uid": "c574-23",
|
|
22
|
+
"name": "createQuery.ts"
|
|
23
23
|
},
|
|
24
24
|
{
|
|
25
|
-
"uid": "
|
|
25
|
+
"uid": "c574-25",
|
|
26
26
|
"name": "createSuspenseQuery.ts"
|
|
27
27
|
},
|
|
28
28
|
{
|
|
29
|
-
"uid": "
|
|
29
|
+
"uid": "c574-27",
|
|
30
30
|
"name": "createInfiniteQuery.ts"
|
|
31
31
|
},
|
|
32
32
|
{
|
|
33
|
-
"uid": "
|
|
33
|
+
"uid": "c574-29",
|
|
34
34
|
"name": "createSuspenseInfiniteQuery.ts"
|
|
35
35
|
},
|
|
36
36
|
{
|
|
37
|
-
"uid": "
|
|
37
|
+
"uid": "c574-31",
|
|
38
38
|
"name": "createMutation.ts"
|
|
39
39
|
},
|
|
40
40
|
{
|
|
41
|
-
"uid": "
|
|
41
|
+
"uid": "c574-33",
|
|
42
42
|
"name": "index.ts"
|
|
43
43
|
}
|
|
44
44
|
]
|
|
@@ -49,273 +49,273 @@
|
|
|
49
49
|
"isRoot": true
|
|
50
50
|
},
|
|
51
51
|
"nodeParts": {
|
|
52
|
-
"
|
|
53
|
-
"renderedLength":
|
|
54
|
-
"gzipLength":
|
|
52
|
+
"c574-19": {
|
|
53
|
+
"renderedLength": 906,
|
|
54
|
+
"gzipLength": 453,
|
|
55
55
|
"brotliLength": 0,
|
|
56
|
-
"mainUid": "
|
|
56
|
+
"mainUid": "c574-18"
|
|
57
57
|
},
|
|
58
|
-
"
|
|
59
|
-
"renderedLength":
|
|
60
|
-
"gzipLength":
|
|
58
|
+
"c574-21": {
|
|
59
|
+
"renderedLength": 1162,
|
|
60
|
+
"gzipLength": 397,
|
|
61
61
|
"brotliLength": 0,
|
|
62
|
-
"mainUid": "
|
|
62
|
+
"mainUid": "c574-20"
|
|
63
63
|
},
|
|
64
|
-
"
|
|
64
|
+
"c574-23": {
|
|
65
65
|
"renderedLength": 91,
|
|
66
66
|
"gzipLength": 87,
|
|
67
67
|
"brotliLength": 0,
|
|
68
|
-
"mainUid": "
|
|
68
|
+
"mainUid": "c574-22"
|
|
69
69
|
},
|
|
70
|
-
"
|
|
71
|
-
"renderedLength":
|
|
72
|
-
"gzipLength":
|
|
70
|
+
"c574-25": {
|
|
71
|
+
"renderedLength": 179,
|
|
72
|
+
"gzipLength": 118,
|
|
73
73
|
"brotliLength": 0,
|
|
74
|
-
"mainUid": "
|
|
74
|
+
"mainUid": "c574-24"
|
|
75
75
|
},
|
|
76
|
-
"
|
|
76
|
+
"c574-27": {
|
|
77
77
|
"renderedLength": 107,
|
|
78
78
|
"gzipLength": 97,
|
|
79
79
|
"brotliLength": 0,
|
|
80
|
-
"mainUid": "
|
|
80
|
+
"mainUid": "c574-26"
|
|
81
81
|
},
|
|
82
|
-
"
|
|
83
|
-
"renderedLength":
|
|
84
|
-
"gzipLength":
|
|
82
|
+
"c574-29": {
|
|
83
|
+
"renderedLength": 203,
|
|
84
|
+
"gzipLength": 128,
|
|
85
85
|
"brotliLength": 0,
|
|
86
|
-
"mainUid": "
|
|
86
|
+
"mainUid": "c574-28"
|
|
87
87
|
},
|
|
88
|
-
"
|
|
89
|
-
"renderedLength":
|
|
90
|
-
"gzipLength":
|
|
88
|
+
"c574-31": {
|
|
89
|
+
"renderedLength": 271,
|
|
90
|
+
"gzipLength": 168,
|
|
91
91
|
"brotliLength": 0,
|
|
92
|
-
"mainUid": "
|
|
92
|
+
"mainUid": "c574-30"
|
|
93
93
|
},
|
|
94
|
-
"
|
|
94
|
+
"c574-33": {
|
|
95
95
|
"renderedLength": 0,
|
|
96
96
|
"gzipLength": 0,
|
|
97
97
|
"brotliLength": 0,
|
|
98
|
-
"mainUid": "
|
|
98
|
+
"mainUid": "c574-32"
|
|
99
99
|
}
|
|
100
100
|
},
|
|
101
101
|
"nodeMetas": {
|
|
102
|
-
"
|
|
102
|
+
"c574-18": {
|
|
103
103
|
"id": "/src/utils.ts",
|
|
104
104
|
"moduleParts": {
|
|
105
|
-
"zip.esm.js": "
|
|
105
|
+
"zip.esm.js": "c574-19"
|
|
106
106
|
},
|
|
107
107
|
"imported": [
|
|
108
108
|
{
|
|
109
|
-
"uid": "
|
|
109
|
+
"uid": "c574-35"
|
|
110
110
|
}
|
|
111
111
|
],
|
|
112
112
|
"importedBy": [
|
|
113
113
|
{
|
|
114
|
-
"uid": "
|
|
114
|
+
"uid": "c574-32"
|
|
115
115
|
},
|
|
116
116
|
{
|
|
117
|
-
"uid": "
|
|
117
|
+
"uid": "c574-24"
|
|
118
118
|
},
|
|
119
119
|
{
|
|
120
|
-
"uid": "
|
|
120
|
+
"uid": "c574-28"
|
|
121
121
|
},
|
|
122
122
|
{
|
|
123
|
-
"uid": "
|
|
123
|
+
"uid": "c574-30"
|
|
124
124
|
},
|
|
125
125
|
{
|
|
126
|
-
"uid": "
|
|
126
|
+
"uid": "c574-20"
|
|
127
127
|
}
|
|
128
128
|
]
|
|
129
129
|
},
|
|
130
|
-
"
|
|
130
|
+
"c574-20": {
|
|
131
131
|
"id": "/src/createBaseQuery.ts",
|
|
132
132
|
"moduleParts": {
|
|
133
|
-
"zip.esm.js": "
|
|
133
|
+
"zip.esm.js": "c574-21"
|
|
134
134
|
},
|
|
135
135
|
"imported": [
|
|
136
136
|
{
|
|
137
|
-
"uid": "
|
|
137
|
+
"uid": "c574-18"
|
|
138
138
|
}
|
|
139
139
|
],
|
|
140
140
|
"importedBy": [
|
|
141
141
|
{
|
|
142
|
-
"uid": "
|
|
142
|
+
"uid": "c574-22"
|
|
143
143
|
},
|
|
144
144
|
{
|
|
145
|
-
"uid": "
|
|
145
|
+
"uid": "c574-24"
|
|
146
146
|
},
|
|
147
147
|
{
|
|
148
|
-
"uid": "
|
|
148
|
+
"uid": "c574-26"
|
|
149
149
|
},
|
|
150
150
|
{
|
|
151
|
-
"uid": "
|
|
151
|
+
"uid": "c574-28"
|
|
152
152
|
}
|
|
153
153
|
]
|
|
154
154
|
},
|
|
155
|
-
"
|
|
156
|
-
"id": "/src/createQuery.
|
|
155
|
+
"c574-22": {
|
|
156
|
+
"id": "/src/createQuery.ts",
|
|
157
157
|
"moduleParts": {
|
|
158
|
-
"zip.esm.js": "
|
|
158
|
+
"zip.esm.js": "c574-23"
|
|
159
159
|
},
|
|
160
160
|
"imported": [
|
|
161
161
|
{
|
|
162
|
-
"uid": "
|
|
162
|
+
"uid": "c574-35"
|
|
163
163
|
},
|
|
164
164
|
{
|
|
165
|
-
"uid": "
|
|
165
|
+
"uid": "c574-20"
|
|
166
166
|
}
|
|
167
167
|
],
|
|
168
168
|
"importedBy": [
|
|
169
169
|
{
|
|
170
|
-
"uid": "
|
|
170
|
+
"uid": "c574-32"
|
|
171
171
|
}
|
|
172
172
|
]
|
|
173
173
|
},
|
|
174
|
-
"
|
|
174
|
+
"c574-24": {
|
|
175
175
|
"id": "/src/createSuspenseQuery.ts",
|
|
176
176
|
"moduleParts": {
|
|
177
|
-
"zip.esm.js": "
|
|
177
|
+
"zip.esm.js": "c574-25"
|
|
178
178
|
},
|
|
179
179
|
"imported": [
|
|
180
180
|
{
|
|
181
|
-
"uid": "
|
|
181
|
+
"uid": "c574-35"
|
|
182
182
|
},
|
|
183
183
|
{
|
|
184
|
-
"uid": "
|
|
184
|
+
"uid": "c574-20"
|
|
185
185
|
},
|
|
186
186
|
{
|
|
187
|
-
"uid": "
|
|
187
|
+
"uid": "c574-18"
|
|
188
188
|
}
|
|
189
189
|
],
|
|
190
190
|
"importedBy": [
|
|
191
191
|
{
|
|
192
|
-
"uid": "
|
|
192
|
+
"uid": "c574-32"
|
|
193
193
|
}
|
|
194
194
|
]
|
|
195
195
|
},
|
|
196
|
-
"
|
|
196
|
+
"c574-26": {
|
|
197
197
|
"id": "/src/createInfiniteQuery.ts",
|
|
198
198
|
"moduleParts": {
|
|
199
|
-
"zip.esm.js": "
|
|
199
|
+
"zip.esm.js": "c574-27"
|
|
200
200
|
},
|
|
201
201
|
"imported": [
|
|
202
202
|
{
|
|
203
|
-
"uid": "
|
|
203
|
+
"uid": "c574-35"
|
|
204
204
|
},
|
|
205
205
|
{
|
|
206
|
-
"uid": "
|
|
206
|
+
"uid": "c574-20"
|
|
207
207
|
}
|
|
208
208
|
],
|
|
209
209
|
"importedBy": [
|
|
210
210
|
{
|
|
211
|
-
"uid": "
|
|
211
|
+
"uid": "c574-32"
|
|
212
212
|
}
|
|
213
213
|
]
|
|
214
214
|
},
|
|
215
|
-
"
|
|
215
|
+
"c574-28": {
|
|
216
216
|
"id": "/src/createSuspenseInfiniteQuery.ts",
|
|
217
217
|
"moduleParts": {
|
|
218
|
-
"zip.esm.js": "
|
|
218
|
+
"zip.esm.js": "c574-29"
|
|
219
219
|
},
|
|
220
220
|
"imported": [
|
|
221
221
|
{
|
|
222
|
-
"uid": "
|
|
222
|
+
"uid": "c574-35"
|
|
223
223
|
},
|
|
224
224
|
{
|
|
225
|
-
"uid": "
|
|
225
|
+
"uid": "c574-20"
|
|
226
226
|
},
|
|
227
227
|
{
|
|
228
|
-
"uid": "
|
|
228
|
+
"uid": "c574-18"
|
|
229
229
|
}
|
|
230
230
|
],
|
|
231
231
|
"importedBy": [
|
|
232
232
|
{
|
|
233
|
-
"uid": "
|
|
233
|
+
"uid": "c574-32"
|
|
234
234
|
}
|
|
235
235
|
]
|
|
236
236
|
},
|
|
237
|
-
"
|
|
237
|
+
"c574-30": {
|
|
238
238
|
"id": "/src/createMutation.ts",
|
|
239
239
|
"moduleParts": {
|
|
240
|
-
"zip.esm.js": "
|
|
240
|
+
"zip.esm.js": "c574-31"
|
|
241
241
|
},
|
|
242
242
|
"imported": [
|
|
243
243
|
{
|
|
244
|
-
"uid": "
|
|
244
|
+
"uid": "c574-35"
|
|
245
245
|
},
|
|
246
246
|
{
|
|
247
|
-
"uid": "
|
|
247
|
+
"uid": "c574-18"
|
|
248
248
|
}
|
|
249
249
|
],
|
|
250
250
|
"importedBy": [
|
|
251
251
|
{
|
|
252
|
-
"uid": "
|
|
252
|
+
"uid": "c574-32"
|
|
253
253
|
}
|
|
254
254
|
]
|
|
255
255
|
},
|
|
256
|
-
"
|
|
256
|
+
"c574-32": {
|
|
257
257
|
"id": "/src/index.ts",
|
|
258
258
|
"moduleParts": {
|
|
259
|
-
"zip.esm.js": "
|
|
259
|
+
"zip.esm.js": "c574-33"
|
|
260
260
|
},
|
|
261
261
|
"imported": [
|
|
262
262
|
{
|
|
263
|
-
"uid": "
|
|
263
|
+
"uid": "c574-22"
|
|
264
264
|
},
|
|
265
265
|
{
|
|
266
|
-
"uid": "
|
|
266
|
+
"uid": "c574-24"
|
|
267
267
|
},
|
|
268
268
|
{
|
|
269
|
-
"uid": "
|
|
269
|
+
"uid": "c574-26"
|
|
270
270
|
},
|
|
271
271
|
{
|
|
272
|
-
"uid": "
|
|
272
|
+
"uid": "c574-28"
|
|
273
273
|
},
|
|
274
274
|
{
|
|
275
|
-
"uid": "
|
|
275
|
+
"uid": "c574-30"
|
|
276
276
|
},
|
|
277
277
|
{
|
|
278
|
-
"uid": "
|
|
278
|
+
"uid": "c574-34"
|
|
279
279
|
},
|
|
280
280
|
{
|
|
281
|
-
"uid": "
|
|
281
|
+
"uid": "c574-18"
|
|
282
282
|
}
|
|
283
283
|
],
|
|
284
284
|
"importedBy": [],
|
|
285
285
|
"isEntry": true
|
|
286
286
|
},
|
|
287
|
-
"
|
|
287
|
+
"c574-34": {
|
|
288
288
|
"id": "/src/types.ts",
|
|
289
289
|
"moduleParts": {},
|
|
290
290
|
"imported": [],
|
|
291
291
|
"importedBy": [
|
|
292
292
|
{
|
|
293
|
-
"uid": "
|
|
293
|
+
"uid": "c574-32"
|
|
294
294
|
}
|
|
295
295
|
]
|
|
296
296
|
},
|
|
297
|
-
"
|
|
297
|
+
"c574-35": {
|
|
298
298
|
"id": "@tanstack/react-query",
|
|
299
299
|
"moduleParts": {},
|
|
300
300
|
"imported": [],
|
|
301
301
|
"importedBy": [
|
|
302
302
|
{
|
|
303
|
-
"uid": "
|
|
303
|
+
"uid": "c574-22"
|
|
304
304
|
},
|
|
305
305
|
{
|
|
306
|
-
"uid": "
|
|
306
|
+
"uid": "c574-24"
|
|
307
307
|
},
|
|
308
308
|
{
|
|
309
|
-
"uid": "
|
|
309
|
+
"uid": "c574-26"
|
|
310
310
|
},
|
|
311
311
|
{
|
|
312
|
-
"uid": "
|
|
312
|
+
"uid": "c574-28"
|
|
313
313
|
},
|
|
314
314
|
{
|
|
315
|
-
"uid": "
|
|
315
|
+
"uid": "c574-30"
|
|
316
316
|
},
|
|
317
317
|
{
|
|
318
|
-
"uid": "
|
|
318
|
+
"uid": "c574-18"
|
|
319
319
|
}
|
|
320
320
|
],
|
|
321
321
|
"isExternal": true
|
|
@@ -24,10 +24,17 @@
|
|
|
24
24
|
|
|
25
25
|
var ReactQuery__namespace = /*#__PURE__*/_interopNamespace(ReactQuery);
|
|
26
26
|
|
|
27
|
+
const isV5 = !!ReactQuery__namespace.useSuspenseQuery; // Compatible with ReactQuery v4
|
|
28
|
+
|
|
29
|
+
const suspenseOptions = {
|
|
30
|
+
enabled: true,
|
|
31
|
+
suspense: true,
|
|
32
|
+
useErrorBoundary: (_error, query) => query.state.data === undefined
|
|
33
|
+
};
|
|
27
34
|
const withMiddleware = (hook, defaultOptions, type) => {
|
|
28
35
|
return function useMiddleware(options, queryClient) {
|
|
29
36
|
const [middleware, opts] = [ReactQuery__namespace.useQueryClient( // @ts-ignore Compatible with ReactQuery v4
|
|
30
|
-
isV5
|
|
37
|
+
isV5 ? queryClient : options).getDefaultOptions()[type], defaultOptions, options].reduce(([u1, o1], {
|
|
31
38
|
use: u2 = [],
|
|
32
39
|
...o2
|
|
33
40
|
} = {}) => [[...u1, ...u2], { ...o1,
|
|
@@ -41,16 +48,9 @@
|
|
|
41
48
|
|
|
42
49
|
return next(opts, queryClient);
|
|
43
50
|
};
|
|
44
|
-
}; // Compatible with ReactQuery v4
|
|
45
|
-
|
|
46
|
-
const suspenseOptions = {
|
|
47
|
-
enabled: true,
|
|
48
|
-
suspense: true,
|
|
49
|
-
useErrorBoundary: (_error, query) => query.state.data === undefined
|
|
50
51
|
};
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
return variables === undefined ? [primaryKey] : [primaryKey, variables];
|
|
52
|
+
const getKey = (queryKey, variables) => {
|
|
53
|
+
return variables === undefined ? [...queryKey] : [...queryKey, variables];
|
|
54
54
|
};
|
|
55
55
|
|
|
56
56
|
const createBaseQuery = (defaultOptions, useRQHook, overrideOptions) => {
|
|
@@ -58,51 +58,58 @@
|
|
|
58
58
|
// @ts-ignore
|
|
59
59
|
if (defaultOptions.useDefaultOptions) {
|
|
60
60
|
console.error('[Bug] useDefaultOptions is not supported, please use middleware instead.');
|
|
61
|
+
} // @ts-ignore
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
if (defaultOptions.queryFn) {
|
|
65
|
+
console.error('[Bug] queryFn is not supported, please use fetcher instead.');
|
|
61
66
|
}
|
|
62
67
|
}
|
|
63
68
|
|
|
64
69
|
const {
|
|
65
|
-
|
|
66
|
-
|
|
70
|
+
queryKey,
|
|
71
|
+
fetcher,
|
|
67
72
|
queryKeyHashFn,
|
|
68
73
|
getPreviousPageParam,
|
|
69
74
|
getNextPageParam,
|
|
70
75
|
initialPageParam
|
|
71
76
|
} = defaultOptions;
|
|
72
77
|
|
|
73
|
-
const
|
|
78
|
+
const getQueryOptions = (fetcherFn, variables) => {
|
|
79
|
+
return {
|
|
80
|
+
queryFn: context => fetcherFn(variables, context),
|
|
81
|
+
queryKey: getKey(queryKey, variables)
|
|
82
|
+
};
|
|
83
|
+
};
|
|
74
84
|
|
|
75
|
-
const getKey$1 = variables => getKey(
|
|
85
|
+
const getKey$1 = variables => getKey(queryKey, variables);
|
|
76
86
|
|
|
77
87
|
const getOptions = variables => {
|
|
78
88
|
return { ...defaultOptions,
|
|
79
|
-
|
|
89
|
+
...getQueryOptions(fetcher, variables)
|
|
80
90
|
};
|
|
81
91
|
};
|
|
82
92
|
|
|
83
93
|
const getFetchOptions = variables => {
|
|
84
94
|
return {
|
|
85
|
-
queryKey: getKey$1(variables),
|
|
86
|
-
queryFn,
|
|
87
95
|
queryKeyHashFn,
|
|
88
96
|
getPreviousPageParam,
|
|
89
97
|
getNextPageParam,
|
|
90
|
-
initialPageParam
|
|
98
|
+
initialPageParam,
|
|
99
|
+
...getQueryOptions(fetcher, variables)
|
|
91
100
|
};
|
|
92
101
|
};
|
|
93
102
|
|
|
94
103
|
const useBaseHook = (options, queryClient) => {
|
|
95
104
|
return useRQHook({ ...options,
|
|
96
105
|
...overrideOptions,
|
|
97
|
-
|
|
106
|
+
...getQueryOptions(options.fetcher, options.variables)
|
|
98
107
|
}, queryClient);
|
|
99
108
|
};
|
|
100
109
|
|
|
101
110
|
return Object.assign(withMiddleware(useBaseHook, defaultOptions, 'queries'), {
|
|
102
|
-
|
|
111
|
+
fetcher,
|
|
103
112
|
getKey: getKey$1,
|
|
104
|
-
queryFn,
|
|
105
|
-
queryKeyHashFn,
|
|
106
113
|
getOptions,
|
|
107
114
|
getFetchOptions
|
|
108
115
|
});
|
|
@@ -113,7 +120,7 @@
|
|
|
113
120
|
};
|
|
114
121
|
|
|
115
122
|
const createSuspenseQuery = options => {
|
|
116
|
-
return isV5
|
|
123
|
+
return isV5 ? createBaseQuery(options, ReactQuery__namespace.useSuspenseQuery) : createBaseQuery(options, ReactQuery__namespace.useQuery, suspenseOptions);
|
|
117
124
|
};
|
|
118
125
|
|
|
119
126
|
const createInfiniteQuery = options => {
|
|
@@ -121,14 +128,13 @@
|
|
|
121
128
|
};
|
|
122
129
|
|
|
123
130
|
const createSuspenseInfiniteQuery = options => {
|
|
124
|
-
return isV5
|
|
131
|
+
return isV5 ? createBaseQuery(options, ReactQuery__namespace.useSuspenseInfiniteQuery) : createBaseQuery(options, ReactQuery__namespace.useInfiniteQuery, suspenseOptions);
|
|
125
132
|
};
|
|
126
133
|
|
|
127
134
|
const createMutation = defaultOptions => {
|
|
128
|
-
const getKey = () => defaultOptions.mutationKey;
|
|
129
|
-
|
|
130
135
|
return Object.assign(withMiddleware(ReactQuery__namespace.useMutation, defaultOptions, 'mutations'), {
|
|
131
|
-
getKey,
|
|
136
|
+
getKey: () => defaultOptions.mutationKey,
|
|
137
|
+
getOptions: () => defaultOptions,
|
|
132
138
|
mutationFn: defaultOptions.mutationFn
|
|
133
139
|
});
|
|
134
140
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.development.js","sources":["../../src/utils.ts","../../src/createBaseQuery.ts","../../src/createQuery.tsx","../../src/createSuspenseQuery.ts","../../src/createInfiniteQuery.ts","../../src/createSuspenseInfiniteQuery.ts","../../src/createMutation.ts"],"sourcesContent":["import * as ReactQuery from '@tanstack/react-query'\n\nimport type { Middleware, inferQueryKey } from './types'\n\nexport const withMiddleware = (\n hook: any,\n defaultOptions: any,\n type: 'queries' | 'mutations'\n) => {\n return function useMiddleware(\n options?: { client?: ReactQuery.QueryClient; use?: Middleware[] },\n queryClient?: ReactQuery.QueryClient\n ) {\n const [middleware, opts] = [\n ReactQuery.useQueryClient(\n // @ts-ignore Compatible with ReactQuery v4\n isV5() ? queryClient : options\n ).getDefaultOptions()[type],\n defaultOptions,\n options,\n ].reduce(\n ([u1, o1], { use: u2 = [], ...o2 } = {}) => [\n [...u1, ...u2],\n { ...o1, ...o2 },\n ],\n [[]]\n )\n\n let next = hook\n for (let i = middleware.length; i--; ) {\n next = middleware[i](next)\n }\n\n return next(opts, queryClient)\n }\n}\n\n// Compatible with ReactQuery v4\nexport const suspenseOptions = {\n enabled: true,\n suspense: true,\n useErrorBoundary: (_error: unknown, query: ReactQuery.Query) =>\n query.state.data === undefined,\n}\n\nexport const isV5 = () => !!ReactQuery.useSuspenseQuery\n\nexport const getKey = <TVariables = void>(\n primaryKey: string,\n variables?: TVariables\n) => {\n return (\n variables === undefined ? [primaryKey] : [primaryKey, variables]\n ) as inferQueryKey<unknown, TVariables>\n}\n","import type {\n QueryClient,\n UseBaseQueryOptions,\n UseInfiniteQueryOptions,\n} from '@tanstack/react-query'\n\nimport type { AdditionalQueryOptions, Middleware } from './types'\nimport { getKey as getQueryKey, withMiddleware } from './utils'\n\ninterface CreateBaseQueryOptions\n extends Omit<UseInfiniteQueryOptions, 'queryKey' | 'queryFn'>,\n AdditionalQueryOptions<any, any> {\n use?: Middleware[]\n variables?: any\n}\n\ntype QueryBaseHookOptions = Omit<\n UseBaseQueryOptions,\n 'queryKey' | 'queryFn'\n> & {\n variables?: any\n}\n\nexport const createBaseQuery = (\n defaultOptions: any,\n useRQHook: (options: any, queryClient?: any) => any,\n overrideOptions?: QueryBaseHookOptions\n): any => {\n if (process.env.NODE_ENV !== 'production') {\n // @ts-ignore\n if (defaultOptions.useDefaultOptions) {\n console.error(\n '[Bug] useDefaultOptions is not supported, please use middleware instead.'\n )\n }\n }\n\n const {\n primaryKey,\n queryFn,\n queryKeyHashFn,\n getPreviousPageParam,\n getNextPageParam,\n initialPageParam,\n } = defaultOptions as CreateBaseQueryOptions\n\n const getPrimaryKey = () => primaryKey\n\n const getKey = (variables?: any) => getQueryKey(primaryKey, variables)\n\n const getOptions = (variables: any) => {\n return {\n ...defaultOptions,\n queryKey: getKey(variables),\n }\n }\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 options: QueryBaseHookOptions,\n queryClient?: QueryClient\n ) => {\n return useRQHook(\n {\n ...options,\n ...overrideOptions,\n queryKey: getKey(options.variables),\n },\n queryClient\n )\n }\n\n return Object.assign(withMiddleware(useBaseHook, defaultOptions, 'queries'), {\n getPrimaryKey,\n getKey,\n queryFn,\n queryKeyHashFn,\n getOptions,\n getFetchOptions,\n })\n}\n","import * as ReactQuery from '@tanstack/react-query'\n\nimport { createBaseQuery } from './createBaseQuery'\nimport type { CompatibleError, CreateQueryOptions, QueryHook } from './types'\n\nexport const createQuery = <\n TFnData,\n TVariables = void,\n TError = CompatibleError\n>(\n options: CreateQueryOptions<TFnData, TVariables, TError>\n): QueryHook<TFnData, TVariables, TError> => {\n return createBaseQuery(options, ReactQuery.useQuery)\n}\n","import * as ReactQuery from '@tanstack/react-query'\n\nimport { createBaseQuery } from './createBaseQuery'\nimport type {\n CompatibleError,\n CreateSuspenseQueryOptions,\n SuspenseQueryHook,\n} from './types'\nimport { isV5, suspenseOptions } from './utils'\n\nexport const createSuspenseQuery = <\n TFnData,\n TVariables = void,\n TError = CompatibleError\n>(\n options: CreateSuspenseQueryOptions<TFnData, TVariables, TError>\n): SuspenseQueryHook<TFnData, TVariables, TError> => {\n return isV5()\n ? createBaseQuery(options, ReactQuery.useSuspenseQuery)\n : createBaseQuery(options, ReactQuery.useQuery, suspenseOptions)\n}\n","import * as ReactQuery from '@tanstack/react-query'\n\nimport { createBaseQuery } from './createBaseQuery'\nimport type {\n CompatibleError,\n CreateInfiniteQueryOptions,\n InfiniteQueryHook,\n} from './types'\n\nexport const createInfiniteQuery = <\n TFnData,\n TVariables = void,\n TError = CompatibleError,\n TPageParam = number\n>(\n options: CreateInfiniteQueryOptions<TFnData, TVariables, TError, TPageParam>\n): InfiniteQueryHook<TFnData, TVariables, TError, TPageParam> => {\n return createBaseQuery(options, ReactQuery.useInfiniteQuery)\n}\n","import * as ReactQuery from '@tanstack/react-query'\n\nimport { createBaseQuery } from './createBaseQuery'\nimport type {\n CompatibleError,\n CreateSuspenseInfiniteQueryOptions,\n SuspenseInfiniteQueryHook,\n} from './types'\nimport { isV5, suspenseOptions } from './utils'\n\nexport const createSuspenseInfiniteQuery = <\n TFnData,\n TVariables = void,\n TError = CompatibleError,\n TPageParam = number\n>(\n options: CreateSuspenseInfiniteQueryOptions<\n TFnData,\n TVariables,\n TError,\n TPageParam\n >\n): SuspenseInfiniteQueryHook<TFnData, TVariables, TError, TPageParam> => {\n return isV5()\n ? createBaseQuery(options, ReactQuery.useSuspenseInfiniteQuery)\n : createBaseQuery(options, ReactQuery.useInfiniteQuery, suspenseOptions)\n}\n","import * as ReactQuery from '@tanstack/react-query'\n\nimport type {\n CompatibleError,\n CreateMutationOptions,\n MutationHook,\n} from './types'\nimport { withMiddleware } from './utils'\n\nexport const createMutation = <\n TData = unknown,\n TVariables = void,\n TError = CompatibleError,\n TContext = unknown\n>(\n defaultOptions: CreateMutationOptions<TData, TVariables, TError, TContext>\n): MutationHook<TData, TVariables, TError> => {\n const getKey = () => defaultOptions.mutationKey\n\n return Object.assign(\n withMiddleware(ReactQuery.useMutation, defaultOptions, 'mutations'),\n {\n getKey,\n mutationFn: defaultOptions.mutationFn,\n }\n ) as MutationHook<TData, TVariables, TError>\n}\n"],"names":["withMiddleware","hook","defaultOptions","type","useMiddleware","options","queryClient","middleware","opts","ReactQuery","useQueryClient","isV5","getDefaultOptions","reduce","u1","o1","use","u2","o2","next","i","length","suspenseOptions","enabled","suspense","useErrorBoundary","_error","query","state","data","undefined","useSuspenseQuery","getKey","primaryKey","variables","createBaseQuery","useRQHook","overrideOptions","useDefaultOptions","console","error","queryFn","queryKeyHashFn","getPreviousPageParam","getNextPageParam","initialPageParam","getPrimaryKey","getQueryKey","getOptions","queryKey","getFetchOptions","useBaseHook","Object","assign","createQuery","useQuery","createSuspenseQuery","createInfiniteQuery","useInfiniteQuery","createSuspenseInfiniteQuery","useSuspenseInfiniteQuery","createMutation","mutationKey","useMutation","mutationFn"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;EAIO,MAAMA,cAAc,GAAG,CAC5BC,IAD4B,EAE5BC,cAF4B,EAG5BC,IAH4B,KAIzB;EACH,EAAA,OAAO,SAASC,aAAT,CACLC,OADK,EAELC,WAFK,EAGL;MACA,MAAM,CAACC,UAAD,EAAaC,IAAb,IAAqB,CACzBC,qBAAU,CAACC,cAAX;MAEEC,IAAI,EAAA,GAAKL,WAAL,GAAmBD,OAFzB,EAGEO,iBAHF,EAAA,CAGsBT,IAHtB,CADyB,EAKzBD,cALyB,EAMzBG,OANyB,CAAA,CAOzBQ,MAPyB,CAQzB,CAAC,CAACC,EAAD,EAAKC,EAAL,CAAD,EAAW;QAAEC,GAAG,EAAEC,EAAE,GAAG,EAAZ;QAAgB,GAAGC,EAAAA;EAAnB,KAAA,GAA0B,EAArC,KAA4C,CAC1C,CAAC,GAAGJ,EAAJ,EAAQ,GAAGG,EAAX,CAD0C,EAE1C,EAAE,GAAGF,EAAL;QAAS,GAAGG,EAAAA;EAAZ,KAF0C,CARnB,EAYzB,CAAC,EAAD,CAZyB,CAA3B,CAAA;MAeA,IAAIC,IAAI,GAAGlB,IAAX,CAAA;;MACA,KAAK,IAAImB,CAAC,GAAGb,UAAU,CAACc,MAAxB,EAAgCD,CAAC,EAAjC,GAAuC;EACrCD,MAAAA,IAAI,GAAGZ,UAAU,CAACa,CAAD,CAAV,CAAcD,IAAd,CAAP,CAAA;EACD,KAAA;;EAED,IAAA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9B,OAAD,EAAUI,qBAAU,CAACmD,wBAArB,CADR,GAEPzB,eAAe,CAAC9B,OAAD,EAAUI,qBAAU,CAACiD,gBAArB,EAAuCpC,eAAvC,CAFnB,CAAA;EAGD;;ACjBYuC,QAAAA,cAAc,GAMzB3D,cAN4B,IAOgB;EAC5C,EAAA,MAAM8B,MAAM,GAAG,MAAM9B,cAAc,CAAC4D,WAApC,CAAA;;EAEA,EAAA,OAAOV,MAAM,CAACC,MAAP,CACLrD,cAAc,CAACS,qBAAU,CAACsD,WAAZ,EAAyB7D,cAAzB,EAAyC,WAAzC,CADT,EAEL;MACE8B,MADF;MAEEgC,UAAU,EAAE9D,cAAc,CAAC8D,UAAAA;EAF7B,GAFK,CAAP,CAAA;EAOD;;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"index.development.js","sources":["../../src/utils.ts","../../src/createBaseQuery.ts","../../src/createQuery.ts","../../src/createSuspenseQuery.ts","../../src/createInfiniteQuery.ts","../../src/createSuspenseInfiniteQuery.ts","../../src/createMutation.ts"],"sourcesContent":["import * as ReactQuery from '@tanstack/react-query'\nimport type { Query, QueryClient, QueryKey } from '@tanstack/react-query'\n\nimport type { Middleware } from './types'\n\nexport const isV5 = !!ReactQuery.useSuspenseQuery\n\n// Compatible with ReactQuery v4\nexport const suspenseOptions = {\n enabled: true,\n suspense: true,\n useErrorBoundary: (_error: unknown, query: Query) =>\n query.state.data === undefined,\n}\n\nexport const withMiddleware = (\n hook: any,\n defaultOptions: any,\n type: 'queries' | 'mutations'\n) => {\n return function useMiddleware(\n options?: { client?: QueryClient; use?: Middleware[] },\n queryClient?: QueryClient\n ) {\n const [middleware, opts] = [\n ReactQuery.useQueryClient(\n // @ts-ignore Compatible with ReactQuery v4\n isV5 ? queryClient : options\n ).getDefaultOptions()[type],\n defaultOptions,\n options,\n ].reduce(\n ([u1, o1], { use: u2 = [], ...o2 } = {}) => [\n [...u1, ...u2],\n { ...o1, ...o2 },\n ],\n [[]]\n )\n\n let next = hook\n for (let i = middleware.length; i--; ) {\n next = middleware[i](next)\n }\n\n return next(opts, queryClient)\n }\n}\n\nexport const getKey = (queryKey: QueryKey, variables?: any): QueryKey => {\n return variables === undefined ? [...queryKey] : [...queryKey, variables]\n}\n","import type {\n QueryClient,\n QueryFunctionContext,\n UseBaseQueryOptions,\n UseInfiniteQueryOptions,\n} from '@tanstack/react-query'\n\nimport type { AdditionalQueryOptions, Middleware } from './types'\nimport { getKey as getFullKey, withMiddleware } from './utils'\n\ninterface CreateBaseQueryOptions\n extends Omit<UseInfiniteQueryOptions, 'queryFn'>,\n AdditionalQueryOptions<any, any> {\n use?: Middleware[]\n variables?: any\n}\n\ntype QueryBaseHookOptions = Omit<\n UseBaseQueryOptions,\n 'queryKey' | 'queryFn'\n> & {\n fetcher?: any\n variables?: any\n}\n\nexport const createBaseQuery = (\n defaultOptions: any,\n useRQHook: (options: any, queryClient?: any) => any,\n overrideOptions?: Partial<UseInfiniteQueryOptions>\n): any => {\n if (process.env.NODE_ENV !== 'production') {\n // @ts-ignore\n if (defaultOptions.useDefaultOptions) {\n console.error(\n '[Bug] useDefaultOptions is not supported, please use middleware instead.'\n )\n }\n\n // @ts-ignore\n if (defaultOptions.queryFn) {\n console.error(\n '[Bug] queryFn is not supported, please use fetcher instead.'\n )\n }\n }\n\n const {\n queryKey,\n fetcher,\n queryKeyHashFn,\n getPreviousPageParam,\n getNextPageParam,\n initialPageParam,\n } = defaultOptions as CreateBaseQueryOptions\n\n const getQueryOptions = (fetcherFn: any, variables: any) => {\n return {\n queryFn: (context: QueryFunctionContext) => fetcherFn(variables, context),\n queryKey: getFullKey(queryKey, variables),\n }\n }\n\n const getKey = (variables?: any) => getFullKey(queryKey, variables)\n\n const getOptions = (variables: any) => {\n return {\n ...defaultOptions,\n ...getQueryOptions(fetcher, variables),\n }\n }\n\n const getFetchOptions = (variables: any) => {\n return {\n queryKeyHashFn,\n getPreviousPageParam,\n getNextPageParam,\n initialPageParam,\n ...getQueryOptions(fetcher, variables),\n }\n }\n\n const useBaseHook = (\n options: QueryBaseHookOptions,\n queryClient?: QueryClient\n ) => {\n return useRQHook(\n {\n ...options,\n ...overrideOptions,\n ...getQueryOptions(options.fetcher, options.variables),\n },\n queryClient\n )\n }\n\n return Object.assign(withMiddleware(useBaseHook, defaultOptions, 'queries'), {\n fetcher,\n getKey,\n getOptions,\n getFetchOptions,\n })\n}\n","import * as ReactQuery from '@tanstack/react-query'\n\nimport { createBaseQuery } from './createBaseQuery'\nimport type { CompatibleError, CreateQueryOptions, QueryHook } from './types'\n\nexport const createQuery = <\n TFnData,\n TVariables = void,\n TError = CompatibleError\n>(\n options: CreateQueryOptions<TFnData, TVariables, TError>\n): QueryHook<TFnData, TVariables, TError> => {\n return createBaseQuery(options, ReactQuery.useQuery)\n}\n","import * as ReactQuery from '@tanstack/react-query'\n\nimport { createBaseQuery } from './createBaseQuery'\nimport type {\n CompatibleError,\n CreateSuspenseQueryOptions,\n SuspenseQueryHook,\n} from './types'\nimport { isV5, suspenseOptions } from './utils'\n\nexport const createSuspenseQuery = <\n TFnData,\n TVariables = void,\n TError = CompatibleError\n>(\n options: CreateSuspenseQueryOptions<TFnData, TVariables, TError>\n): SuspenseQueryHook<TFnData, TVariables, TError> => {\n return isV5\n ? createBaseQuery(options, ReactQuery.useSuspenseQuery)\n : createBaseQuery(options, ReactQuery.useQuery, suspenseOptions)\n}\n","import * as ReactQuery from '@tanstack/react-query'\n\nimport { createBaseQuery } from './createBaseQuery'\nimport type {\n CompatibleError,\n CreateInfiniteQueryOptions,\n InfiniteQueryHook,\n} from './types'\n\nexport const createInfiniteQuery = <\n TFnData,\n TVariables = void,\n TError = CompatibleError,\n TPageParam = number\n>(\n options: CreateInfiniteQueryOptions<TFnData, TVariables, TError, TPageParam>\n): InfiniteQueryHook<TFnData, TVariables, TError, TPageParam> => {\n return createBaseQuery(options, ReactQuery.useInfiniteQuery)\n}\n","import * as ReactQuery from '@tanstack/react-query'\n\nimport { createBaseQuery } from './createBaseQuery'\nimport type {\n CompatibleError,\n CreateSuspenseInfiniteQueryOptions,\n SuspenseInfiniteQueryHook,\n} from './types'\nimport { isV5, suspenseOptions } from './utils'\n\nexport const createSuspenseInfiniteQuery = <\n TFnData,\n TVariables = void,\n TError = CompatibleError,\n TPageParam = number\n>(\n options: CreateSuspenseInfiniteQueryOptions<\n TFnData,\n TVariables,\n TError,\n TPageParam\n >\n): SuspenseInfiniteQueryHook<TFnData, TVariables, TError, TPageParam> => {\n return isV5\n ? createBaseQuery(options, ReactQuery.useSuspenseInfiniteQuery)\n : createBaseQuery(options, ReactQuery.useInfiniteQuery, suspenseOptions)\n}\n","import * as ReactQuery from '@tanstack/react-query'\n\nimport type {\n CompatibleError,\n CreateMutationOptions,\n MutationHook,\n} from './types'\nimport { withMiddleware } from './utils'\n\nexport const createMutation = <\n TData = unknown,\n TVariables = void,\n TError = CompatibleError,\n TContext = unknown\n>(\n defaultOptions: CreateMutationOptions<TData, TVariables, TError, TContext>\n): MutationHook<TData, TVariables, TError, TContext> => {\n return Object.assign(\n withMiddleware(ReactQuery.useMutation, defaultOptions, 'mutations'),\n {\n getKey: () => defaultOptions.mutationKey,\n getOptions: () => defaultOptions,\n mutationFn: defaultOptions.mutationFn,\n }\n ) as MutationHook<TData, TVariables, TError, TContext>\n}\n"],"names":["isV5","ReactQuery","useSuspenseQuery","suspenseOptions","enabled","suspense","useErrorBoundary","_error","query","state","data","undefined","withMiddleware","hook","defaultOptions","type","useMiddleware","options","queryClient","middleware","opts","useQueryClient","getDefaultOptions","reduce","u1","o1","use","u2","o2","next","i","length","getKey","queryKey","variables","createBaseQuery","useRQHook","overrideOptions","useDefaultOptions","console","error","queryFn","fetcher","queryKeyHashFn","getPreviousPageParam","getNextPageParam","initialPageParam","getQueryOptions","fetcherFn","context","getFullKey","getOptions","getFetchOptions","useBaseHook","Object","assign","createQuery","useQuery","createSuspenseQuery","createInfiniteQuery","useInfiniteQuery","createSuspenseInfiniteQuery","useSuspenseInfiniteQuery","create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AClB,OAAD,EAAUhB,qBAAU,CAAC6D,wBAArB,CADR,GAEP3B,eAAe,CAAClB,OAAD,EAAUhB,qBAAU,CAAC2D,gBAArB,EAAuCzD,eAAvC,CAFnB,CAAA;EAGD;;ACjBY4D,QAAAA,cAAc,GAMzBjD,cAN4B,IAO0B;EACtD,EAAA,OAAOwC,MAAM,CAACC,MAAP,CACL3C,cAAc,CAACX,qBAAU,CAAC+D,WAAZ,EAAyBlD,cAAzB,EAAyC,WAAzC,CADT,EAEL;EACEkB,IAAAA,MAAM,EAAE,MAAMlB,cAAc,CAACmD,WAD/B;MAEEd,UAAU,EAAE,MAAMrC,cAFpB;MAGEoD,UAAU,EAAEpD,cAAc,CAACoD,UAAAA;EAH7B,GAFK,CAAP,CAAA;EAQD;;;;;;;;;;;;;;;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@tanstack/react-query")):"function"==typeof define&&define.amd?define(["exports","@tanstack/react-query"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).ReactQueryKit={},e.ReactQuery)}(this,(function(e,t){"use strict";function r(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@tanstack/react-query")):"function"==typeof define&&define.amd?define(["exports","@tanstack/react-query"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).ReactQueryKit={},e.ReactQuery)}(this,(function(e,t){"use strict";function r(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var n=r(t);const u=!!n.useSuspenseQuery,a={enabled:!0,suspense:!0,useErrorBoundary:(e,t)=>void 0===t.state.data},i=(e,t,r)=>function(a,i){const[s,o]=[n.useQueryClient(u?i:a).getDefaultOptions()[r],t,a].reduce((([e,t],{use:r=[],...n}={})=>[[...e,...r],{...t,...n}]),[[]]);let c=e;for(let e=s.length;e--;)c=s[e](c);return c(o,i)},s=(e,t)=>void 0===t?[...e]:[...e,t],o=(e,t,r)=>{const{queryKey:n,fetcher:u,queryKeyHashFn:a,getPreviousPageParam:o,getNextPageParam:c,initialPageParam:y}=e,f=(e,t)=>({queryFn:r=>e(t,r),queryKey:s(n,t)});return Object.assign(i(((e,n)=>t({...e,...r,...f(e.fetcher,e.variables)},n)),e,"queries"),{fetcher:u,getKey:e=>s(n,e),getOptions:t=>({...e,...f(u,t)}),getFetchOptions:e=>({queryKeyHashFn:a,getPreviousPageParam:o,getNextPageParam:c,initialPageParam:y,...f(u,e)})})};e.createInfiniteQuery=e=>o(e,n.useInfiniteQuery),e.createMutation=e=>Object.assign(i(n.useMutation,e,"mutations"),{getKey:()=>e.mutationKey,getOptions:()=>e,mutationFn:e.mutationFn}),e.createQuery=e=>o(e,n.useQuery),e.createSuspenseInfiniteQuery=e=>u?o(e,n.useSuspenseInfiniteQuery):o(e,n.useInfiniteQuery,a),e.createSuspenseQuery=e=>u?o(e,n.useSuspenseQuery):o(e,n.useQuery,a),e.getKey=s,Object.defineProperty(e,"__esModule",{value:!0})}));
|
|
2
2
|
//# sourceMappingURL=index.production.js.map
|