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/build/stats.json
CHANGED
|
@@ -10,39 +10,35 @@
|
|
|
10
10
|
"name": "src",
|
|
11
11
|
"children": [
|
|
12
12
|
{
|
|
13
|
-
"uid": "
|
|
13
|
+
"uid": "1405-18",
|
|
14
14
|
"name": "utils.ts"
|
|
15
15
|
},
|
|
16
16
|
{
|
|
17
|
-
"uid": "
|
|
17
|
+
"uid": "1405-20",
|
|
18
18
|
"name": "createBaseQuery.ts"
|
|
19
19
|
},
|
|
20
20
|
{
|
|
21
|
-
"uid": "
|
|
21
|
+
"uid": "1405-22",
|
|
22
22
|
"name": "createQuery.tsx"
|
|
23
23
|
},
|
|
24
24
|
{
|
|
25
|
-
"uid": "
|
|
26
|
-
"name": "createImmutableQuery.tsx"
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
"uid": "d114-28",
|
|
25
|
+
"uid": "1405-24",
|
|
30
26
|
"name": "createSuspenseQuery.ts"
|
|
31
27
|
},
|
|
32
28
|
{
|
|
33
|
-
"uid": "
|
|
29
|
+
"uid": "1405-26",
|
|
34
30
|
"name": "createInfiniteQuery.ts"
|
|
35
31
|
},
|
|
36
32
|
{
|
|
37
|
-
"uid": "
|
|
33
|
+
"uid": "1405-28",
|
|
38
34
|
"name": "createSuspenseInfiniteQuery.ts"
|
|
39
35
|
},
|
|
40
36
|
{
|
|
41
|
-
"uid": "
|
|
37
|
+
"uid": "1405-30",
|
|
42
38
|
"name": "createMutation.ts"
|
|
43
39
|
},
|
|
44
40
|
{
|
|
45
|
-
"uid": "
|
|
41
|
+
"uid": "1405-32",
|
|
46
42
|
"name": "index.ts"
|
|
47
43
|
}
|
|
48
44
|
]
|
|
@@ -53,282 +49,248 @@
|
|
|
53
49
|
"isRoot": true
|
|
54
50
|
},
|
|
55
51
|
"nodeParts": {
|
|
56
|
-
"
|
|
57
|
-
"renderedLength":
|
|
58
|
-
"gzipLength":
|
|
59
|
-
"brotliLength": 0,
|
|
60
|
-
"mainUid": "d114-19"
|
|
61
|
-
},
|
|
62
|
-
"d114-22": {
|
|
63
|
-
"renderedLength": 1585,
|
|
64
|
-
"gzipLength": 512,
|
|
52
|
+
"1405-18": {
|
|
53
|
+
"renderedLength": 831,
|
|
54
|
+
"gzipLength": 395,
|
|
65
55
|
"brotliLength": 0,
|
|
66
|
-
"mainUid": "
|
|
56
|
+
"mainUid": "1405-17"
|
|
67
57
|
},
|
|
68
|
-
"
|
|
69
|
-
"renderedLength":
|
|
70
|
-
"gzipLength":
|
|
58
|
+
"1405-20": {
|
|
59
|
+
"renderedLength": 999,
|
|
60
|
+
"gzipLength": 361,
|
|
71
61
|
"brotliLength": 0,
|
|
72
|
-
"mainUid": "
|
|
62
|
+
"mainUid": "1405-19"
|
|
73
63
|
},
|
|
74
|
-
"
|
|
75
|
-
"renderedLength":
|
|
76
|
-
"gzipLength":
|
|
64
|
+
"1405-22": {
|
|
65
|
+
"renderedLength": 97,
|
|
66
|
+
"gzipLength": 90,
|
|
77
67
|
"brotliLength": 0,
|
|
78
|
-
"mainUid": "
|
|
68
|
+
"mainUid": "1405-21"
|
|
79
69
|
},
|
|
80
|
-
"
|
|
81
|
-
"renderedLength":
|
|
82
|
-
"gzipLength":
|
|
70
|
+
"1405-24": {
|
|
71
|
+
"renderedLength": 271,
|
|
72
|
+
"gzipLength": 177,
|
|
83
73
|
"brotliLength": 0,
|
|
84
|
-
"mainUid": "
|
|
74
|
+
"mainUid": "1405-23"
|
|
85
75
|
},
|
|
86
|
-
"
|
|
87
|
-
"renderedLength":
|
|
88
|
-
"gzipLength":
|
|
76
|
+
"1405-26": {
|
|
77
|
+
"renderedLength": 113,
|
|
78
|
+
"gzipLength": 99,
|
|
89
79
|
"brotliLength": 0,
|
|
90
|
-
"mainUid": "
|
|
80
|
+
"mainUid": "1405-25"
|
|
91
81
|
},
|
|
92
|
-
"
|
|
93
|
-
"renderedLength":
|
|
94
|
-
"gzipLength":
|
|
82
|
+
"1405-28": {
|
|
83
|
+
"renderedLength": 287,
|
|
84
|
+
"gzipLength": 186,
|
|
95
85
|
"brotliLength": 0,
|
|
96
|
-
"mainUid": "
|
|
86
|
+
"mainUid": "1405-27"
|
|
97
87
|
},
|
|
98
|
-
"
|
|
99
|
-
"renderedLength":
|
|
100
|
-
"gzipLength":
|
|
88
|
+
"1405-30": {
|
|
89
|
+
"renderedLength": 265,
|
|
90
|
+
"gzipLength": 173,
|
|
101
91
|
"brotliLength": 0,
|
|
102
|
-
"mainUid": "
|
|
92
|
+
"mainUid": "1405-29"
|
|
103
93
|
},
|
|
104
|
-
"
|
|
94
|
+
"1405-32": {
|
|
105
95
|
"renderedLength": 0,
|
|
106
96
|
"gzipLength": 0,
|
|
107
97
|
"brotliLength": 0,
|
|
108
|
-
"mainUid": "
|
|
98
|
+
"mainUid": "1405-31"
|
|
109
99
|
}
|
|
110
100
|
},
|
|
111
101
|
"nodeMetas": {
|
|
112
|
-
"
|
|
102
|
+
"1405-17": {
|
|
113
103
|
"id": "/src/utils.ts",
|
|
114
104
|
"moduleParts": {
|
|
115
|
-
"index.production.js": "
|
|
105
|
+
"index.production.js": "1405-18"
|
|
116
106
|
},
|
|
117
107
|
"imported": [
|
|
118
108
|
{
|
|
119
|
-
"uid": "
|
|
109
|
+
"uid": "1405-33"
|
|
120
110
|
}
|
|
121
111
|
],
|
|
122
112
|
"importedBy": [
|
|
123
113
|
{
|
|
124
|
-
"uid": "
|
|
114
|
+
"uid": "1405-31"
|
|
125
115
|
},
|
|
126
116
|
{
|
|
127
|
-
"uid": "
|
|
117
|
+
"uid": "1405-29"
|
|
128
118
|
},
|
|
129
119
|
{
|
|
130
|
-
"uid": "
|
|
120
|
+
"uid": "1405-19"
|
|
131
121
|
}
|
|
132
122
|
]
|
|
133
123
|
},
|
|
134
|
-
"
|
|
124
|
+
"1405-19": {
|
|
135
125
|
"id": "/src/createBaseQuery.ts",
|
|
136
126
|
"moduleParts": {
|
|
137
|
-
"index.production.js": "
|
|
127
|
+
"index.production.js": "1405-20"
|
|
138
128
|
},
|
|
139
129
|
"imported": [
|
|
140
130
|
{
|
|
141
|
-
"uid": "
|
|
131
|
+
"uid": "1405-17"
|
|
142
132
|
}
|
|
143
133
|
],
|
|
144
134
|
"importedBy": [
|
|
145
135
|
{
|
|
146
|
-
"uid": "
|
|
147
|
-
},
|
|
148
|
-
{
|
|
149
|
-
"uid": "d114-25"
|
|
136
|
+
"uid": "1405-21"
|
|
150
137
|
},
|
|
151
138
|
{
|
|
152
|
-
"uid": "
|
|
139
|
+
"uid": "1405-23"
|
|
153
140
|
},
|
|
154
141
|
{
|
|
155
|
-
"uid": "
|
|
142
|
+
"uid": "1405-25"
|
|
156
143
|
},
|
|
157
144
|
{
|
|
158
|
-
"uid": "
|
|
145
|
+
"uid": "1405-27"
|
|
159
146
|
}
|
|
160
147
|
]
|
|
161
148
|
},
|
|
162
|
-
"
|
|
149
|
+
"1405-21": {
|
|
163
150
|
"id": "/src/createQuery.tsx",
|
|
164
151
|
"moduleParts": {
|
|
165
|
-
"index.production.js": "
|
|
152
|
+
"index.production.js": "1405-22"
|
|
166
153
|
},
|
|
167
154
|
"imported": [
|
|
168
155
|
{
|
|
169
|
-
"uid": "
|
|
156
|
+
"uid": "1405-33"
|
|
170
157
|
},
|
|
171
158
|
{
|
|
172
|
-
"uid": "
|
|
159
|
+
"uid": "1405-19"
|
|
173
160
|
}
|
|
174
161
|
],
|
|
175
162
|
"importedBy": [
|
|
176
163
|
{
|
|
177
|
-
"uid": "
|
|
164
|
+
"uid": "1405-31"
|
|
178
165
|
}
|
|
179
166
|
]
|
|
180
167
|
},
|
|
181
|
-
"
|
|
182
|
-
"id": "/src/createImmutableQuery.tsx",
|
|
183
|
-
"moduleParts": {
|
|
184
|
-
"index.production.js": "d114-26"
|
|
185
|
-
},
|
|
186
|
-
"imported": [
|
|
187
|
-
{
|
|
188
|
-
"uid": "d114-37"
|
|
189
|
-
},
|
|
190
|
-
{
|
|
191
|
-
"uid": "d114-21"
|
|
192
|
-
}
|
|
193
|
-
],
|
|
194
|
-
"importedBy": [
|
|
195
|
-
{
|
|
196
|
-
"uid": "d114-35"
|
|
197
|
-
}
|
|
198
|
-
]
|
|
199
|
-
},
|
|
200
|
-
"d114-27": {
|
|
168
|
+
"1405-23": {
|
|
201
169
|
"id": "/src/createSuspenseQuery.ts",
|
|
202
170
|
"moduleParts": {
|
|
203
|
-
"index.production.js": "
|
|
171
|
+
"index.production.js": "1405-24"
|
|
204
172
|
},
|
|
205
173
|
"imported": [
|
|
206
174
|
{
|
|
207
|
-
"uid": "
|
|
175
|
+
"uid": "1405-33"
|
|
208
176
|
},
|
|
209
177
|
{
|
|
210
|
-
"uid": "
|
|
178
|
+
"uid": "1405-19"
|
|
211
179
|
}
|
|
212
180
|
],
|
|
213
181
|
"importedBy": [
|
|
214
182
|
{
|
|
215
|
-
"uid": "
|
|
183
|
+
"uid": "1405-31"
|
|
216
184
|
}
|
|
217
185
|
]
|
|
218
186
|
},
|
|
219
|
-
"
|
|
187
|
+
"1405-25": {
|
|
220
188
|
"id": "/src/createInfiniteQuery.ts",
|
|
221
189
|
"moduleParts": {
|
|
222
|
-
"index.production.js": "
|
|
190
|
+
"index.production.js": "1405-26"
|
|
223
191
|
},
|
|
224
192
|
"imported": [
|
|
225
193
|
{
|
|
226
|
-
"uid": "
|
|
194
|
+
"uid": "1405-33"
|
|
227
195
|
},
|
|
228
196
|
{
|
|
229
|
-
"uid": "
|
|
197
|
+
"uid": "1405-19"
|
|
230
198
|
}
|
|
231
199
|
],
|
|
232
200
|
"importedBy": [
|
|
233
201
|
{
|
|
234
|
-
"uid": "
|
|
202
|
+
"uid": "1405-31"
|
|
235
203
|
}
|
|
236
204
|
]
|
|
237
205
|
},
|
|
238
|
-
"
|
|
206
|
+
"1405-27": {
|
|
239
207
|
"id": "/src/createSuspenseInfiniteQuery.ts",
|
|
240
208
|
"moduleParts": {
|
|
241
|
-
"index.production.js": "
|
|
209
|
+
"index.production.js": "1405-28"
|
|
242
210
|
},
|
|
243
211
|
"imported": [
|
|
244
212
|
{
|
|
245
|
-
"uid": "
|
|
213
|
+
"uid": "1405-33"
|
|
246
214
|
},
|
|
247
215
|
{
|
|
248
|
-
"uid": "
|
|
216
|
+
"uid": "1405-19"
|
|
249
217
|
}
|
|
250
218
|
],
|
|
251
219
|
"importedBy": [
|
|
252
220
|
{
|
|
253
|
-
"uid": "
|
|
221
|
+
"uid": "1405-31"
|
|
254
222
|
}
|
|
255
223
|
]
|
|
256
224
|
},
|
|
257
|
-
"
|
|
225
|
+
"1405-29": {
|
|
258
226
|
"id": "/src/createMutation.ts",
|
|
259
227
|
"moduleParts": {
|
|
260
|
-
"index.production.js": "
|
|
228
|
+
"index.production.js": "1405-30"
|
|
261
229
|
},
|
|
262
230
|
"imported": [
|
|
263
231
|
{
|
|
264
|
-
"uid": "
|
|
232
|
+
"uid": "1405-33"
|
|
265
233
|
},
|
|
266
234
|
{
|
|
267
|
-
"uid": "
|
|
235
|
+
"uid": "1405-17"
|
|
268
236
|
}
|
|
269
237
|
],
|
|
270
238
|
"importedBy": [
|
|
271
239
|
{
|
|
272
|
-
"uid": "
|
|
240
|
+
"uid": "1405-31"
|
|
273
241
|
}
|
|
274
242
|
]
|
|
275
243
|
},
|
|
276
|
-
"
|
|
244
|
+
"1405-31": {
|
|
277
245
|
"id": "/src/index.ts",
|
|
278
246
|
"moduleParts": {
|
|
279
|
-
"index.production.js": "
|
|
247
|
+
"index.production.js": "1405-32"
|
|
280
248
|
},
|
|
281
249
|
"imported": [
|
|
282
250
|
{
|
|
283
|
-
"uid": "
|
|
284
|
-
},
|
|
285
|
-
{
|
|
286
|
-
"uid": "d114-25"
|
|
251
|
+
"uid": "1405-21"
|
|
287
252
|
},
|
|
288
253
|
{
|
|
289
|
-
"uid": "
|
|
254
|
+
"uid": "1405-23"
|
|
290
255
|
},
|
|
291
256
|
{
|
|
292
|
-
"uid": "
|
|
257
|
+
"uid": "1405-25"
|
|
293
258
|
},
|
|
294
259
|
{
|
|
295
|
-
"uid": "
|
|
260
|
+
"uid": "1405-27"
|
|
296
261
|
},
|
|
297
262
|
{
|
|
298
|
-
"uid": "
|
|
263
|
+
"uid": "1405-29"
|
|
299
264
|
},
|
|
300
265
|
{
|
|
301
|
-
"uid": "
|
|
266
|
+
"uid": "1405-17"
|
|
302
267
|
}
|
|
303
268
|
],
|
|
304
269
|
"importedBy": [],
|
|
305
270
|
"isEntry": true
|
|
306
271
|
},
|
|
307
|
-
"
|
|
272
|
+
"1405-33": {
|
|
308
273
|
"id": "@tanstack/react-query",
|
|
309
274
|
"moduleParts": {},
|
|
310
275
|
"imported": [],
|
|
311
276
|
"importedBy": [
|
|
312
277
|
{
|
|
313
|
-
"uid": "
|
|
314
|
-
},
|
|
315
|
-
{
|
|
316
|
-
"uid": "d114-25"
|
|
278
|
+
"uid": "1405-21"
|
|
317
279
|
},
|
|
318
280
|
{
|
|
319
|
-
"uid": "
|
|
281
|
+
"uid": "1405-23"
|
|
320
282
|
},
|
|
321
283
|
{
|
|
322
|
-
"uid": "
|
|
284
|
+
"uid": "1405-25"
|
|
323
285
|
},
|
|
324
286
|
{
|
|
325
|
-
"uid": "
|
|
287
|
+
"uid": "1405-27"
|
|
326
288
|
},
|
|
327
289
|
{
|
|
328
|
-
"uid": "
|
|
290
|
+
"uid": "1405-29"
|
|
329
291
|
},
|
|
330
292
|
{
|
|
331
|
-
"uid": "
|
|
293
|
+
"uid": "1405-17"
|
|
332
294
|
}
|
|
333
295
|
],
|
|
334
296
|
"isExternal": true
|
|
@@ -4,41 +4,39 @@
|
|
|
4
4
|
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.ReactQueryKit = {}, global.ReactQuery));
|
|
5
5
|
})(this, (function (exports, reactQuery) { 'use strict';
|
|
6
6
|
|
|
7
|
-
const
|
|
8
|
-
reactQuery.useQueryClient(options != null && options.context ? {
|
|
9
|
-
context: options.context
|
|
10
|
-
} : queryClient);
|
|
11
|
-
const withMiddlewares = (hook, defaultOptions, type) => {
|
|
12
|
-
const {
|
|
13
|
-
use = [],
|
|
14
|
-
...restOptions
|
|
15
|
-
} = defaultOptions;
|
|
7
|
+
const withMiddleware = (hook, defaultOptions, type) => {
|
|
16
8
|
return function useMiddleware(options, queryClient) {
|
|
17
|
-
const
|
|
9
|
+
const [middleware, opts] = [reactQuery.useQueryClient( // compatible with ReactQuery v4
|
|
10
|
+
// @ts-ignore
|
|
11
|
+
options != null && options.context ? {
|
|
12
|
+
context: options.context
|
|
13
|
+
} : queryClient).getDefaultOptions()[type], defaultOptions, options].reduce(([middleware, opts], {
|
|
14
|
+
use = [],
|
|
15
|
+
...rest
|
|
16
|
+
} = {}) => [[...middleware, ...use], { ...opts,
|
|
17
|
+
...rest
|
|
18
|
+
}], [[], {}]);
|
|
18
19
|
let next = hook;
|
|
19
|
-
const {
|
|
20
|
-
use: configUse = [],
|
|
21
|
-
...configOptions
|
|
22
|
-
} = client.getDefaultOptions()[type] || {};
|
|
23
|
-
const middleware = configUse.concat(use);
|
|
24
20
|
|
|
25
21
|
for (let i = middleware.length; i--;) {
|
|
26
22
|
next = middleware[i](next);
|
|
27
23
|
}
|
|
28
24
|
|
|
29
|
-
return next(
|
|
30
|
-
...restOptions,
|
|
31
|
-
...options
|
|
32
|
-
}, queryClient);
|
|
25
|
+
return next(opts, queryClient);
|
|
33
26
|
};
|
|
34
27
|
};
|
|
35
|
-
const
|
|
28
|
+
const getKey = (primaryKey, variables) => {
|
|
36
29
|
return variables === undefined ? [primaryKey] : [primaryKey, variables];
|
|
37
30
|
};
|
|
38
31
|
|
|
39
32
|
function createBaseQuery(defaultOptions, useRQHook, overrideOptions) {
|
|
40
33
|
const {
|
|
41
|
-
primaryKey
|
|
34
|
+
primaryKey,
|
|
35
|
+
queryFn,
|
|
36
|
+
queryKeyHashFn,
|
|
37
|
+
getPreviousPageParam,
|
|
38
|
+
getNextPageParam,
|
|
39
|
+
initialPageParam
|
|
42
40
|
} = defaultOptions;
|
|
43
41
|
|
|
44
42
|
{
|
|
@@ -50,68 +48,43 @@
|
|
|
50
48
|
|
|
51
49
|
const getPrimaryKey = () => primaryKey;
|
|
52
50
|
|
|
53
|
-
const getKey = variables =>
|
|
51
|
+
const getKey$1 = variables => getKey(primaryKey, variables);
|
|
54
52
|
|
|
55
53
|
const getFetchOptions = variables => {
|
|
56
54
|
return {
|
|
57
|
-
queryKey: getKey(variables),
|
|
58
|
-
queryFn
|
|
59
|
-
queryKeyHashFn
|
|
60
|
-
getPreviousPageParam
|
|
61
|
-
getNextPageParam
|
|
62
|
-
initialPageParam
|
|
55
|
+
queryKey: getKey$1(variables),
|
|
56
|
+
queryFn,
|
|
57
|
+
queryKeyHashFn,
|
|
58
|
+
getPreviousPageParam,
|
|
59
|
+
getNextPageParam,
|
|
60
|
+
initialPageParam
|
|
63
61
|
};
|
|
64
62
|
};
|
|
65
63
|
|
|
66
|
-
const
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
...
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
};
|
|
75
|
-
const queryKey = getKey(variables);
|
|
76
|
-
const result = useRQHook({ ...mergedOptions,
|
|
77
|
-
enabled: typeof enabled === 'function' ? enabled(client.getQueryData(queryKey), variables) : enabled,
|
|
78
|
-
queryKey
|
|
79
|
-
}, client);
|
|
80
|
-
return Object.assign(result, {
|
|
81
|
-
queryKey: queryKey,
|
|
82
|
-
variables,
|
|
83
|
-
setData: (updater, setDataOptions) => client.setQueryData(queryKey, updater, setDataOptions)
|
|
84
|
-
});
|
|
64
|
+
const useBaseHook = ({
|
|
65
|
+
variables,
|
|
66
|
+
...rest
|
|
67
|
+
}, queryClient) => {
|
|
68
|
+
return useRQHook({ ...rest,
|
|
69
|
+
...overrideOptions,
|
|
70
|
+
queryKey: getKey$1(variables)
|
|
71
|
+
}, queryClient);
|
|
85
72
|
};
|
|
86
73
|
|
|
87
|
-
return Object.assign(
|
|
74
|
+
return Object.assign(withMiddleware(useBaseHook, defaultOptions, 'queries'), {
|
|
88
75
|
getPrimaryKey,
|
|
89
|
-
getKey,
|
|
90
|
-
queryFn
|
|
91
|
-
queryKeyHashFn
|
|
76
|
+
getKey: getKey$1,
|
|
77
|
+
queryFn,
|
|
78
|
+
queryKeyHashFn,
|
|
92
79
|
getFetchOptions
|
|
93
80
|
});
|
|
94
81
|
}
|
|
95
82
|
|
|
96
|
-
|
|
83
|
+
const createQuery = options => {
|
|
97
84
|
return createBaseQuery(options, reactQuery.useQuery);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
function createImmutableQuery(options) {
|
|
101
|
-
return createBaseQuery(options, reactQuery.useQuery, {
|
|
102
|
-
refetchInterval: false,
|
|
103
|
-
refetchOnMount: false,
|
|
104
|
-
refetchOnReconnect: false,
|
|
105
|
-
refetchOnWindowFocus: false,
|
|
106
|
-
staleTime: Infinity,
|
|
107
|
-
gcTime: Infinity,
|
|
108
|
-
// compatible with ReactQuery v4
|
|
109
|
-
// @ts-ignore
|
|
110
|
-
cacheTime: Infinity
|
|
111
|
-
});
|
|
112
|
-
}
|
|
85
|
+
};
|
|
113
86
|
|
|
114
|
-
|
|
87
|
+
const createSuspenseQuery = options => {
|
|
115
88
|
return createBaseQuery(options, reactQuery.useQuery, {
|
|
116
89
|
enabled: true,
|
|
117
90
|
suspense: true,
|
|
@@ -120,13 +93,13 @@
|
|
|
120
93
|
// @ts-ignore
|
|
121
94
|
useErrorBoundary: true
|
|
122
95
|
});
|
|
123
|
-
}
|
|
96
|
+
};
|
|
124
97
|
|
|
125
|
-
|
|
98
|
+
const createInfiniteQuery = options => {
|
|
126
99
|
return createBaseQuery(options, reactQuery.useInfiniteQuery);
|
|
127
|
-
}
|
|
100
|
+
};
|
|
128
101
|
|
|
129
|
-
|
|
102
|
+
const createSuspenseInfiniteQuery = options => {
|
|
130
103
|
return createBaseQuery(options, reactQuery.useInfiniteQuery, {
|
|
131
104
|
enabled: true,
|
|
132
105
|
suspense: true,
|
|
@@ -135,24 +108,23 @@
|
|
|
135
108
|
// @ts-ignore
|
|
136
109
|
useErrorBoundary: true
|
|
137
110
|
});
|
|
138
|
-
}
|
|
111
|
+
};
|
|
139
112
|
|
|
140
|
-
|
|
113
|
+
const createMutation = defaultOptions => {
|
|
141
114
|
const getKey = () => defaultOptions.mutationKey;
|
|
142
115
|
|
|
143
|
-
return Object.assign(
|
|
116
|
+
return Object.assign(withMiddleware(reactQuery.useMutation, defaultOptions, 'mutations'), {
|
|
144
117
|
getKey,
|
|
145
118
|
mutationFn: defaultOptions.mutationFn
|
|
146
119
|
});
|
|
147
|
-
}
|
|
120
|
+
};
|
|
148
121
|
|
|
149
|
-
exports.createImmutableQuery = createImmutableQuery;
|
|
150
122
|
exports.createInfiniteQuery = createInfiniteQuery;
|
|
151
123
|
exports.createMutation = createMutation;
|
|
152
124
|
exports.createQuery = createQuery;
|
|
153
125
|
exports.createSuspenseInfiniteQuery = createSuspenseInfiniteQuery;
|
|
154
126
|
exports.createSuspenseQuery = createSuspenseQuery;
|
|
155
|
-
exports.
|
|
127
|
+
exports.getKey = getKey;
|
|
156
128
|
|
|
157
129
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
158
130
|
|