@pyreon/query 0.3.0 → 0.4.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/lib/analysis/index.js.html +1 -1
- package/lib/index.js +270 -139
- package/lib/index.js.map +1 -1
- package/lib/types/index.d.ts +278 -147
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/index2.d.ts +162 -104
- package/lib/types/index2.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/index.ts +42 -44
- package/src/query-client.ts +3 -4
- package/src/tests/{query.test.ts → query.test.tsx} +254 -353
- package/src/tests/subscription.test.tsx +581 -0
- package/src/use-infinite-query.ts +2 -2
- package/src/use-is-fetching.ts +1 -1
- package/src/use-mutation.ts +2 -2
- package/src/use-queries.ts +2 -2
- package/src/use-query-error-reset-boundary.ts +3 -4
- package/src/use-query.ts +2 -2
- package/src/use-subscription.ts +226 -0
- package/src/use-suspense-query.ts +3 -3
|
@@ -1,23 +1,22 @@
|
|
|
1
|
-
import { QueryClient } from '@tanstack/query-core'
|
|
2
|
-
import { h } from '@pyreon/core'
|
|
3
1
|
import { signal } from '@pyreon/reactivity'
|
|
4
2
|
import { mount } from '@pyreon/runtime-dom'
|
|
3
|
+
import { QueryClient } from '@tanstack/query-core'
|
|
5
4
|
import {
|
|
5
|
+
dehydrate,
|
|
6
|
+
hydrate,
|
|
6
7
|
QueryClientProvider,
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
QueryErrorResetBoundary,
|
|
9
|
+
QuerySuspense,
|
|
10
|
+
useInfiniteQuery,
|
|
10
11
|
useIsFetching,
|
|
11
12
|
useIsMutating,
|
|
13
|
+
useMutation,
|
|
12
14
|
useQueries,
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
useInfiniteQuery,
|
|
16
|
-
QuerySuspense,
|
|
17
|
-
QueryErrorResetBoundary,
|
|
15
|
+
useQuery,
|
|
16
|
+
useQueryClient,
|
|
18
17
|
useQueryErrorResetBoundary,
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
useSuspenseInfiniteQuery,
|
|
19
|
+
useSuspenseQuery,
|
|
21
20
|
} from '../index'
|
|
22
21
|
|
|
23
22
|
// ─── Helpers ──────────────────────────────────────────────────────────────────
|
|
@@ -33,10 +32,12 @@ function _withProvider(client: QueryClient, component: () => void): () => void {
|
|
|
33
32
|
const el = document.createElement('div')
|
|
34
33
|
document.body.appendChild(el)
|
|
35
34
|
const unmount = mount(
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
35
|
+
<QueryClientProvider client={client}>
|
|
36
|
+
{() => {
|
|
37
|
+
component()
|
|
38
|
+
return null
|
|
39
|
+
}}
|
|
40
|
+
</QueryClientProvider>,
|
|
40
41
|
el,
|
|
41
42
|
)
|
|
42
43
|
return () => {
|
|
@@ -70,14 +71,12 @@ describe('QueryClientProvider / useQueryClient', () => {
|
|
|
70
71
|
const el = document.createElement('div')
|
|
71
72
|
document.body.appendChild(el)
|
|
72
73
|
const unmount = mount(
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
{ client },
|
|
76
|
-
h(() => {
|
|
74
|
+
<QueryClientProvider client={client}>
|
|
75
|
+
{() => {
|
|
77
76
|
received = useQueryClient()
|
|
78
77
|
return null
|
|
79
|
-
}
|
|
80
|
-
|
|
78
|
+
}}
|
|
79
|
+
</QueryClientProvider>,
|
|
81
80
|
el,
|
|
82
81
|
)
|
|
83
82
|
unmount()
|
|
@@ -92,18 +91,14 @@ describe('QueryClientProvider / useQueryClient', () => {
|
|
|
92
91
|
const el = document.createElement('div')
|
|
93
92
|
document.body.appendChild(el)
|
|
94
93
|
const unmount = mount(
|
|
95
|
-
|
|
96
|
-
QueryClientProvider
|
|
97
|
-
|
|
98
|
-
h(
|
|
99
|
-
QueryClientProvider,
|
|
100
|
-
{ client: inner },
|
|
101
|
-
h(() => {
|
|
94
|
+
<QueryClientProvider client={outer}>
|
|
95
|
+
<QueryClientProvider client={inner}>
|
|
96
|
+
{() => {
|
|
102
97
|
received = useQueryClient()
|
|
103
98
|
return null
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
|
|
99
|
+
}}
|
|
100
|
+
</QueryClientProvider>
|
|
101
|
+
</QueryClientProvider>,
|
|
107
102
|
el,
|
|
108
103
|
)
|
|
109
104
|
unmount()
|
|
@@ -126,10 +121,8 @@ describe('useQuery', () => {
|
|
|
126
121
|
const el = document.createElement('div')
|
|
127
122
|
document.body.appendChild(el)
|
|
128
123
|
const unmount = mount(
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
{ client },
|
|
132
|
-
h(() => {
|
|
124
|
+
<QueryClientProvider client={client}>
|
|
125
|
+
{() => {
|
|
133
126
|
query = useQuery(() => ({
|
|
134
127
|
queryKey: ['test-pending'],
|
|
135
128
|
queryFn: () =>
|
|
@@ -138,8 +131,8 @@ describe('useQuery', () => {
|
|
|
138
131
|
}), // never resolves
|
|
139
132
|
}))
|
|
140
133
|
return null
|
|
141
|
-
}
|
|
142
|
-
|
|
134
|
+
}}
|
|
135
|
+
</QueryClientProvider>,
|
|
143
136
|
el,
|
|
144
137
|
)
|
|
145
138
|
expect(query!.isPending()).toBe(true)
|
|
@@ -155,17 +148,15 @@ describe('useQuery', () => {
|
|
|
155
148
|
const el = document.createElement('div')
|
|
156
149
|
document.body.appendChild(el)
|
|
157
150
|
const unmount = mount(
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
{ client },
|
|
161
|
-
h(() => {
|
|
151
|
+
<QueryClientProvider client={client}>
|
|
152
|
+
{() => {
|
|
162
153
|
query = useQuery(() => ({
|
|
163
154
|
queryKey: ['test-success'],
|
|
164
155
|
queryFn: () => promise,
|
|
165
156
|
}))
|
|
166
157
|
return null
|
|
167
|
-
}
|
|
168
|
-
|
|
158
|
+
}}
|
|
159
|
+
</QueryClientProvider>,
|
|
169
160
|
el,
|
|
170
161
|
)
|
|
171
162
|
|
|
@@ -188,17 +179,15 @@ describe('useQuery', () => {
|
|
|
188
179
|
const el = document.createElement('div')
|
|
189
180
|
document.body.appendChild(el)
|
|
190
181
|
const unmount = mount(
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
{ client },
|
|
194
|
-
h(() => {
|
|
182
|
+
<QueryClientProvider client={client}>
|
|
183
|
+
{() => {
|
|
195
184
|
query = useQuery(() => ({
|
|
196
185
|
queryKey: ['test-error'],
|
|
197
186
|
queryFn: () => promise,
|
|
198
187
|
}))
|
|
199
188
|
return null
|
|
200
|
-
}
|
|
201
|
-
|
|
189
|
+
}}
|
|
190
|
+
</QueryClientProvider>,
|
|
202
191
|
el,
|
|
203
192
|
)
|
|
204
193
|
|
|
@@ -221,18 +210,16 @@ describe('useQuery', () => {
|
|
|
221
210
|
const el = document.createElement('div')
|
|
222
211
|
document.body.appendChild(el)
|
|
223
212
|
const unmount = mount(
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
{ client },
|
|
227
|
-
h(() => {
|
|
213
|
+
<QueryClientProvider client={client}>
|
|
214
|
+
{() => {
|
|
228
215
|
query = useQuery(() => ({
|
|
229
216
|
queryKey: ['test-disabled'],
|
|
230
217
|
queryFn,
|
|
231
218
|
enabled: false,
|
|
232
219
|
}))
|
|
233
220
|
return null
|
|
234
|
-
}
|
|
235
|
-
|
|
221
|
+
}}
|
|
222
|
+
</QueryClientProvider>,
|
|
236
223
|
el,
|
|
237
224
|
)
|
|
238
225
|
|
|
@@ -252,10 +239,8 @@ describe('useQuery', () => {
|
|
|
252
239
|
const el = document.createElement('div')
|
|
253
240
|
document.body.appendChild(el)
|
|
254
241
|
const unmount = mount(
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
{ client },
|
|
258
|
-
h(() => {
|
|
242
|
+
<QueryClientProvider client={client}>
|
|
243
|
+
{() => {
|
|
259
244
|
query = useQuery(() => ({
|
|
260
245
|
queryKey: ['user', userId()],
|
|
261
246
|
queryFn: async () => {
|
|
@@ -265,8 +250,8 @@ describe('useQuery', () => {
|
|
|
265
250
|
},
|
|
266
251
|
}))
|
|
267
252
|
return null
|
|
268
|
-
}
|
|
269
|
-
|
|
253
|
+
}}
|
|
254
|
+
</QueryClientProvider>,
|
|
270
255
|
el,
|
|
271
256
|
)
|
|
272
257
|
|
|
@@ -287,10 +272,8 @@ describe('useQuery', () => {
|
|
|
287
272
|
const el = document.createElement('div')
|
|
288
273
|
document.body.appendChild(el)
|
|
289
274
|
const unmount = mount(
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
{ client },
|
|
293
|
-
h(() => {
|
|
275
|
+
<QueryClientProvider client={client}>
|
|
276
|
+
{() => {
|
|
294
277
|
useQuery(() => ({
|
|
295
278
|
queryKey: ['invalidate-test'],
|
|
296
279
|
queryFn: async () => {
|
|
@@ -299,8 +282,8 @@ describe('useQuery', () => {
|
|
|
299
282
|
},
|
|
300
283
|
}))
|
|
301
284
|
return null
|
|
302
|
-
}
|
|
303
|
-
|
|
285
|
+
}}
|
|
286
|
+
</QueryClientProvider>,
|
|
304
287
|
el,
|
|
305
288
|
)
|
|
306
289
|
|
|
@@ -327,14 +310,12 @@ describe('useMutation', () => {
|
|
|
327
310
|
const el = document.createElement('div')
|
|
328
311
|
document.body.appendChild(el)
|
|
329
312
|
const unmount = mount(
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
{ client },
|
|
333
|
-
h(() => {
|
|
313
|
+
<QueryClientProvider client={client}>
|
|
314
|
+
{() => {
|
|
334
315
|
mut = useMutation({ mutationFn: () => Promise.resolve('ok') })
|
|
335
316
|
return null
|
|
336
|
-
}
|
|
337
|
-
|
|
317
|
+
}}
|
|
318
|
+
</QueryClientProvider>,
|
|
338
319
|
el,
|
|
339
320
|
)
|
|
340
321
|
expect(mut!.isIdle()).toBe(true)
|
|
@@ -348,16 +329,14 @@ describe('useMutation', () => {
|
|
|
348
329
|
const el = document.createElement('div')
|
|
349
330
|
document.body.appendChild(el)
|
|
350
331
|
const unmount = mount(
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
{ client },
|
|
354
|
-
h(() => {
|
|
332
|
+
<QueryClientProvider client={client}>
|
|
333
|
+
{() => {
|
|
355
334
|
mut = useMutation<string, Error, string>({
|
|
356
335
|
mutationFn: async (input: string) => `result:${input}`,
|
|
357
336
|
})
|
|
358
337
|
return null
|
|
359
|
-
}
|
|
360
|
-
|
|
338
|
+
}}
|
|
339
|
+
</QueryClientProvider>,
|
|
361
340
|
el,
|
|
362
341
|
)
|
|
363
342
|
|
|
@@ -375,18 +354,16 @@ describe('useMutation', () => {
|
|
|
375
354
|
const el = document.createElement('div')
|
|
376
355
|
document.body.appendChild(el)
|
|
377
356
|
const unmount = mount(
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
{ client },
|
|
381
|
-
h(() => {
|
|
357
|
+
<QueryClientProvider client={client}>
|
|
358
|
+
{() => {
|
|
382
359
|
mut = useMutation({
|
|
383
360
|
mutationFn: async () => {
|
|
384
361
|
throw new Error('mutation failed')
|
|
385
362
|
},
|
|
386
363
|
})
|
|
387
364
|
return null
|
|
388
|
-
}
|
|
389
|
-
|
|
365
|
+
}}
|
|
366
|
+
</QueryClientProvider>,
|
|
390
367
|
el,
|
|
391
368
|
)
|
|
392
369
|
|
|
@@ -404,16 +381,14 @@ describe('useMutation', () => {
|
|
|
404
381
|
const el = document.createElement('div')
|
|
405
382
|
document.body.appendChild(el)
|
|
406
383
|
const unmount = mount(
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
{ client },
|
|
410
|
-
h(() => {
|
|
384
|
+
<QueryClientProvider client={client}>
|
|
385
|
+
{() => {
|
|
411
386
|
mut = useMutation<string, Error, void>({
|
|
412
387
|
mutationFn: async () => 'done',
|
|
413
388
|
})
|
|
414
389
|
return null
|
|
415
|
-
}
|
|
416
|
-
|
|
390
|
+
}}
|
|
391
|
+
</QueryClientProvider>,
|
|
417
392
|
el,
|
|
418
393
|
)
|
|
419
394
|
|
|
@@ -439,14 +414,12 @@ describe('useIsFetching', () => {
|
|
|
439
414
|
const el = document.createElement('div')
|
|
440
415
|
document.body.appendChild(el)
|
|
441
416
|
const unmount = mount(
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
{ client },
|
|
445
|
-
h(() => {
|
|
417
|
+
<QueryClientProvider client={client}>
|
|
418
|
+
{() => {
|
|
446
419
|
count = useIsFetching()
|
|
447
420
|
return null
|
|
448
|
-
}
|
|
449
|
-
|
|
421
|
+
}}
|
|
422
|
+
</QueryClientProvider>,
|
|
450
423
|
el,
|
|
451
424
|
)
|
|
452
425
|
expect(count!()).toBe(0)
|
|
@@ -463,18 +436,16 @@ describe('useIsFetching', () => {
|
|
|
463
436
|
const el = document.createElement('div')
|
|
464
437
|
document.body.appendChild(el)
|
|
465
438
|
const unmount = mount(
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
{ client },
|
|
469
|
-
h(() => {
|
|
439
|
+
<QueryClientProvider client={client}>
|
|
440
|
+
{() => {
|
|
470
441
|
isFetching = useIsFetching()
|
|
471
442
|
useQuery(() => ({
|
|
472
443
|
queryKey: ['fetch-count'],
|
|
473
444
|
queryFn: () => promise,
|
|
474
445
|
}))
|
|
475
446
|
return null
|
|
476
|
-
}
|
|
477
|
-
|
|
447
|
+
}}
|
|
448
|
+
</QueryClientProvider>,
|
|
478
449
|
el,
|
|
479
450
|
)
|
|
480
451
|
|
|
@@ -504,15 +475,13 @@ describe('useIsMutating', () => {
|
|
|
504
475
|
const el = document.createElement('div')
|
|
505
476
|
document.body.appendChild(el)
|
|
506
477
|
const unmount = mount(
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
{ client },
|
|
510
|
-
h(() => {
|
|
478
|
+
<QueryClientProvider client={client}>
|
|
479
|
+
{() => {
|
|
511
480
|
isMutating = useIsMutating()
|
|
512
481
|
mut = useMutation<void, Error, void>({ mutationFn: () => promise })
|
|
513
482
|
return null
|
|
514
|
-
}
|
|
515
|
-
|
|
483
|
+
}}
|
|
484
|
+
</QueryClientProvider>,
|
|
516
485
|
el,
|
|
517
486
|
)
|
|
518
487
|
|
|
@@ -551,10 +520,8 @@ describe('dehydrate / hydrate', () => {
|
|
|
551
520
|
const el = document.createElement('div')
|
|
552
521
|
document.body.appendChild(el)
|
|
553
522
|
const unmount = mount(
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
{ client: clientClient },
|
|
557
|
-
h(() => {
|
|
523
|
+
<QueryClientProvider client={clientClient}>
|
|
524
|
+
{() => {
|
|
558
525
|
query = useQuery(() => ({
|
|
559
526
|
queryKey: ['ssr-user'],
|
|
560
527
|
queryFn: async () => {
|
|
@@ -564,8 +531,8 @@ describe('dehydrate / hydrate', () => {
|
|
|
564
531
|
staleTime: Infinity, // treat hydrated data as fresh
|
|
565
532
|
}))
|
|
566
533
|
return null
|
|
567
|
-
}
|
|
568
|
-
|
|
534
|
+
}}
|
|
535
|
+
</QueryClientProvider>,
|
|
569
536
|
el,
|
|
570
537
|
)
|
|
571
538
|
|
|
@@ -589,17 +556,15 @@ describe('useQueries', () => {
|
|
|
589
556
|
const el = document.createElement('div')
|
|
590
557
|
document.body.appendChild(el)
|
|
591
558
|
const unmount = mount(
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
{ client },
|
|
595
|
-
h(() => {
|
|
559
|
+
<QueryClientProvider client={client}>
|
|
560
|
+
{() => {
|
|
596
561
|
results = useQueries(() => [
|
|
597
562
|
{ queryKey: ['a'], queryFn: async () => 'alpha' },
|
|
598
563
|
{ queryKey: ['b'], queryFn: async () => 'beta' },
|
|
599
564
|
])
|
|
600
565
|
return null
|
|
601
|
-
}
|
|
602
|
-
|
|
566
|
+
}}
|
|
567
|
+
</QueryClientProvider>,
|
|
603
568
|
el,
|
|
604
569
|
)
|
|
605
570
|
|
|
@@ -621,10 +586,8 @@ describe('useQueries', () => {
|
|
|
621
586
|
const el = document.createElement('div')
|
|
622
587
|
document.body.appendChild(el)
|
|
623
588
|
const unmount = mount(
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
{ client },
|
|
627
|
-
h(() => {
|
|
589
|
+
<QueryClientProvider client={client}>
|
|
590
|
+
{() => {
|
|
628
591
|
results = useQueries(() =>
|
|
629
592
|
ids().map((id) => ({
|
|
630
593
|
queryKey: ['item', id],
|
|
@@ -632,8 +595,8 @@ describe('useQueries', () => {
|
|
|
632
595
|
})),
|
|
633
596
|
)
|
|
634
597
|
return null
|
|
635
|
-
}
|
|
636
|
-
|
|
598
|
+
}}
|
|
599
|
+
</QueryClientProvider>,
|
|
637
600
|
el,
|
|
638
601
|
)
|
|
639
602
|
|
|
@@ -664,24 +627,22 @@ describe('useSuspenseQuery + QuerySuspense', () => {
|
|
|
664
627
|
const el = document.createElement('div')
|
|
665
628
|
document.body.appendChild(el)
|
|
666
629
|
const unmount = mount(
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
{ client },
|
|
670
|
-
h(() => {
|
|
630
|
+
<QueryClientProvider client={client}>
|
|
631
|
+
{() => {
|
|
671
632
|
const q = useSuspenseQuery(() => ({
|
|
672
633
|
queryKey: ['sq-pending'],
|
|
673
634
|
queryFn: () => promise,
|
|
674
635
|
}))
|
|
675
|
-
return
|
|
676
|
-
QuerySuspense
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
636
|
+
return (
|
|
637
|
+
<QuerySuspense query={q} fallback="loading">
|
|
638
|
+
{() => {
|
|
639
|
+
rendered.push(q.data())
|
|
640
|
+
return null
|
|
641
|
+
}}
|
|
642
|
+
</QuerySuspense>
|
|
682
643
|
)
|
|
683
|
-
}
|
|
684
|
-
|
|
644
|
+
}}
|
|
645
|
+
</QueryClientProvider>,
|
|
685
646
|
el,
|
|
686
647
|
)
|
|
687
648
|
|
|
@@ -704,28 +665,26 @@ describe('useSuspenseQuery + QuerySuspense', () => {
|
|
|
704
665
|
const el = document.createElement('div')
|
|
705
666
|
document.body.appendChild(el)
|
|
706
667
|
const unmount = mount(
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
{ client },
|
|
710
|
-
h(() => {
|
|
668
|
+
<QueryClientProvider client={client}>
|
|
669
|
+
{() => {
|
|
711
670
|
const q = useSuspenseQuery(() => ({
|
|
712
671
|
queryKey: ['sq-error'],
|
|
713
672
|
queryFn: () => promise,
|
|
714
673
|
}))
|
|
715
|
-
return
|
|
716
|
-
QuerySuspense
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
error: (err: unknown) => {
|
|
674
|
+
return (
|
|
675
|
+
<QuerySuspense
|
|
676
|
+
query={q}
|
|
677
|
+
fallback="loading"
|
|
678
|
+
error={(err: unknown) => {
|
|
721
679
|
errorMsg = (err as Error).message
|
|
722
680
|
return null
|
|
723
|
-
}
|
|
724
|
-
|
|
725
|
-
|
|
681
|
+
}}
|
|
682
|
+
>
|
|
683
|
+
{() => null}
|
|
684
|
+
</QuerySuspense>
|
|
726
685
|
)
|
|
727
|
-
}
|
|
728
|
-
|
|
686
|
+
}}
|
|
687
|
+
</QueryClientProvider>,
|
|
729
688
|
el,
|
|
730
689
|
)
|
|
731
690
|
|
|
@@ -747,10 +706,8 @@ describe('useSuspenseQuery + QuerySuspense', () => {
|
|
|
747
706
|
const el = document.createElement('div')
|
|
748
707
|
document.body.appendChild(el)
|
|
749
708
|
const unmount = mount(
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
{ client },
|
|
753
|
-
h(() => {
|
|
709
|
+
<QueryClientProvider client={client}>
|
|
710
|
+
{() => {
|
|
754
711
|
const q1 = useSuspenseQuery(() => ({
|
|
755
712
|
queryKey: ['mq1'],
|
|
756
713
|
queryFn: () => d1.promise,
|
|
@@ -759,16 +716,16 @@ describe('useSuspenseQuery + QuerySuspense', () => {
|
|
|
759
716
|
queryKey: ['mq2'],
|
|
760
717
|
queryFn: () => d2.promise,
|
|
761
718
|
}))
|
|
762
|
-
return
|
|
763
|
-
QuerySuspense
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
719
|
+
return (
|
|
720
|
+
<QuerySuspense query={[q1, q2]} fallback="loading">
|
|
721
|
+
{() => {
|
|
722
|
+
childrenRendered = true
|
|
723
|
+
return null
|
|
724
|
+
}}
|
|
725
|
+
</QuerySuspense>
|
|
769
726
|
)
|
|
770
|
-
}
|
|
771
|
-
|
|
727
|
+
}}
|
|
728
|
+
</QueryClientProvider>,
|
|
772
729
|
el,
|
|
773
730
|
)
|
|
774
731
|
|
|
@@ -799,13 +756,9 @@ describe('QueryErrorResetBoundary', () => {
|
|
|
799
756
|
const el = document.createElement('div')
|
|
800
757
|
document.body.appendChild(el)
|
|
801
758
|
const unmount = mount(
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
h(
|
|
806
|
-
QueryErrorResetBoundary,
|
|
807
|
-
null,
|
|
808
|
-
h(() => {
|
|
759
|
+
<QueryClientProvider client={client}>
|
|
760
|
+
<QueryErrorResetBoundary>
|
|
761
|
+
{() => {
|
|
809
762
|
const { reset } = useQueryErrorResetBoundary()
|
|
810
763
|
resetFn = reset
|
|
811
764
|
useQuery(() => ({
|
|
@@ -817,9 +770,9 @@ describe('QueryErrorResetBoundary', () => {
|
|
|
817
770
|
},
|
|
818
771
|
}))
|
|
819
772
|
return null
|
|
820
|
-
}
|
|
821
|
-
|
|
822
|
-
|
|
773
|
+
}}
|
|
774
|
+
</QueryErrorResetBoundary>
|
|
775
|
+
</QueryClientProvider>,
|
|
823
776
|
el,
|
|
824
777
|
)
|
|
825
778
|
|
|
@@ -841,15 +794,13 @@ describe('QueryErrorResetBoundary', () => {
|
|
|
841
794
|
const el = document.createElement('div')
|
|
842
795
|
document.body.appendChild(el)
|
|
843
796
|
const unmount = mount(
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
{ client },
|
|
847
|
-
h(() => {
|
|
797
|
+
<QueryClientProvider client={client}>
|
|
798
|
+
{() => {
|
|
848
799
|
const boundary = useQueryErrorResetBoundary()
|
|
849
800
|
reset = boundary.reset
|
|
850
801
|
return null
|
|
851
|
-
}
|
|
852
|
-
|
|
802
|
+
}}
|
|
803
|
+
</QueryClientProvider>,
|
|
853
804
|
el,
|
|
854
805
|
)
|
|
855
806
|
|
|
@@ -873,10 +824,8 @@ describe('useInfiniteQuery', () => {
|
|
|
873
824
|
const el = document.createElement('div')
|
|
874
825
|
document.body.appendChild(el)
|
|
875
826
|
const unmount = mount(
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
{ client },
|
|
879
|
-
h(() => {
|
|
827
|
+
<QueryClientProvider client={client}>
|
|
828
|
+
{() => {
|
|
880
829
|
query = useInfiniteQuery(() => ({
|
|
881
830
|
queryKey: ['inf-pending'],
|
|
882
831
|
queryFn: () =>
|
|
@@ -887,8 +836,8 @@ describe('useInfiniteQuery', () => {
|
|
|
887
836
|
getNextPageParam: () => undefined,
|
|
888
837
|
}))
|
|
889
838
|
return null
|
|
890
|
-
}
|
|
891
|
-
|
|
839
|
+
}}
|
|
840
|
+
</QueryClientProvider>,
|
|
892
841
|
el,
|
|
893
842
|
)
|
|
894
843
|
expect(query!.isPending()).toBe(true)
|
|
@@ -911,10 +860,8 @@ describe('useInfiniteQuery', () => {
|
|
|
911
860
|
const el = document.createElement('div')
|
|
912
861
|
document.body.appendChild(el)
|
|
913
862
|
const unmount = mount(
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
{ client },
|
|
917
|
-
h(() => {
|
|
863
|
+
<QueryClientProvider client={client}>
|
|
864
|
+
{() => {
|
|
918
865
|
query = useInfiniteQuery(() => ({
|
|
919
866
|
queryKey: ['inf-success'],
|
|
920
867
|
queryFn: ({ pageParam }: { pageParam: number }) =>
|
|
@@ -927,8 +874,8 @@ describe('useInfiniteQuery', () => {
|
|
|
927
874
|
) => (lastParam < 2 ? lastParam + 1 : undefined),
|
|
928
875
|
}))
|
|
929
876
|
return null
|
|
930
|
-
}
|
|
931
|
-
|
|
877
|
+
}}
|
|
878
|
+
</QueryClientProvider>,
|
|
932
879
|
el,
|
|
933
880
|
)
|
|
934
881
|
|
|
@@ -948,10 +895,8 @@ describe('useInfiniteQuery', () => {
|
|
|
948
895
|
const el = document.createElement('div')
|
|
949
896
|
document.body.appendChild(el)
|
|
950
897
|
const unmount = mount(
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
{ client },
|
|
954
|
-
h(() => {
|
|
898
|
+
<QueryClientProvider client={client}>
|
|
899
|
+
{() => {
|
|
955
900
|
query = useInfiniteQuery(() => ({
|
|
956
901
|
queryKey: ['inf-next'],
|
|
957
902
|
queryFn: ({ pageParam }: { pageParam: number }) =>
|
|
@@ -964,8 +909,8 @@ describe('useInfiniteQuery', () => {
|
|
|
964
909
|
) => (lastParam < 2 ? lastParam + 1 : undefined),
|
|
965
910
|
}))
|
|
966
911
|
return null
|
|
967
|
-
}
|
|
968
|
-
|
|
912
|
+
}}
|
|
913
|
+
</QueryClientProvider>,
|
|
969
914
|
el,
|
|
970
915
|
)
|
|
971
916
|
|
|
@@ -990,10 +935,8 @@ describe('useInfiniteQuery', () => {
|
|
|
990
935
|
const el = document.createElement('div')
|
|
991
936
|
document.body.appendChild(el)
|
|
992
937
|
const unmount = mount(
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
{ client },
|
|
996
|
-
h(() => {
|
|
938
|
+
<QueryClientProvider client={client}>
|
|
939
|
+
{() => {
|
|
997
940
|
query = useInfiniteQuery(() => ({
|
|
998
941
|
queryKey: ['inf-prev'],
|
|
999
942
|
queryFn: ({ pageParam }: { pageParam: number }) =>
|
|
@@ -1007,8 +950,8 @@ describe('useInfiniteQuery', () => {
|
|
|
1007
950
|
) => (firstParam > 3 ? firstParam - 1 : undefined),
|
|
1008
951
|
}))
|
|
1009
952
|
return null
|
|
1010
|
-
}
|
|
1011
|
-
|
|
953
|
+
}}
|
|
954
|
+
</QueryClientProvider>,
|
|
1012
955
|
el,
|
|
1013
956
|
)
|
|
1014
957
|
|
|
@@ -1027,10 +970,8 @@ describe('useInfiniteQuery', () => {
|
|
|
1027
970
|
const el = document.createElement('div')
|
|
1028
971
|
document.body.appendChild(el)
|
|
1029
972
|
const unmount = mount(
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
{ client },
|
|
1033
|
-
h(() => {
|
|
973
|
+
<QueryClientProvider client={client}>
|
|
974
|
+
{() => {
|
|
1034
975
|
query = useInfiniteQuery(() => ({
|
|
1035
976
|
queryKey: ['inf-error'],
|
|
1036
977
|
queryFn: () => Promise.reject(new Error('inf failed')),
|
|
@@ -1038,8 +979,8 @@ describe('useInfiniteQuery', () => {
|
|
|
1038
979
|
getNextPageParam: () => undefined,
|
|
1039
980
|
}))
|
|
1040
981
|
return null
|
|
1041
|
-
}
|
|
1042
|
-
|
|
982
|
+
}}
|
|
983
|
+
</QueryClientProvider>,
|
|
1043
984
|
el,
|
|
1044
985
|
)
|
|
1045
986
|
|
|
@@ -1057,10 +998,8 @@ describe('useInfiniteQuery', () => {
|
|
|
1057
998
|
const el = document.createElement('div')
|
|
1058
999
|
document.body.appendChild(el)
|
|
1059
1000
|
const unmount = mount(
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
{ client },
|
|
1063
|
-
h(() => {
|
|
1001
|
+
<QueryClientProvider client={client}>
|
|
1002
|
+
{() => {
|
|
1064
1003
|
query = useInfiniteQuery(() => ({
|
|
1065
1004
|
queryKey: ['inf-refetch'],
|
|
1066
1005
|
queryFn: () => {
|
|
@@ -1071,8 +1010,8 @@ describe('useInfiniteQuery', () => {
|
|
|
1071
1010
|
getNextPageParam: () => undefined,
|
|
1072
1011
|
}))
|
|
1073
1012
|
return null
|
|
1074
|
-
}
|
|
1075
|
-
|
|
1013
|
+
}}
|
|
1014
|
+
</QueryClientProvider>,
|
|
1076
1015
|
el,
|
|
1077
1016
|
)
|
|
1078
1017
|
|
|
@@ -1090,10 +1029,8 @@ describe('useInfiniteQuery', () => {
|
|
|
1090
1029
|
const el = document.createElement('div')
|
|
1091
1030
|
document.body.appendChild(el)
|
|
1092
1031
|
const unmount = mount(
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
{ client },
|
|
1096
|
-
h(() => {
|
|
1032
|
+
<QueryClientProvider client={client}>
|
|
1033
|
+
{() => {
|
|
1097
1034
|
query = useInfiniteQuery(() => ({
|
|
1098
1035
|
queryKey: ['inf-result'],
|
|
1099
1036
|
queryFn: () => Promise.resolve('val'),
|
|
@@ -1101,8 +1038,8 @@ describe('useInfiniteQuery', () => {
|
|
|
1101
1038
|
getNextPageParam: () => undefined,
|
|
1102
1039
|
}))
|
|
1103
1040
|
return null
|
|
1104
|
-
}
|
|
1105
|
-
|
|
1041
|
+
}}
|
|
1042
|
+
</QueryClientProvider>,
|
|
1106
1043
|
el,
|
|
1107
1044
|
)
|
|
1108
1045
|
|
|
@@ -1120,10 +1057,8 @@ describe('useInfiniteQuery', () => {
|
|
|
1120
1057
|
const el = document.createElement('div')
|
|
1121
1058
|
document.body.appendChild(el)
|
|
1122
1059
|
const unmount = mount(
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
{ client },
|
|
1126
|
-
h(() => {
|
|
1060
|
+
<QueryClientProvider client={client}>
|
|
1061
|
+
{() => {
|
|
1127
1062
|
query = useInfiniteQuery(() => ({
|
|
1128
1063
|
queryKey: ['inf-reactive', key()],
|
|
1129
1064
|
queryFn: () => Promise.resolve(`data-${key()}`),
|
|
@@ -1131,8 +1066,8 @@ describe('useInfiniteQuery', () => {
|
|
|
1131
1066
|
getNextPageParam: () => undefined,
|
|
1132
1067
|
}))
|
|
1133
1068
|
return null
|
|
1134
|
-
}
|
|
1135
|
-
|
|
1069
|
+
}}
|
|
1070
|
+
</QueryClientProvider>,
|
|
1136
1071
|
el,
|
|
1137
1072
|
)
|
|
1138
1073
|
|
|
@@ -1160,10 +1095,8 @@ describe('useSuspenseInfiniteQuery', () => {
|
|
|
1160
1095
|
const el = document.createElement('div')
|
|
1161
1096
|
document.body.appendChild(el)
|
|
1162
1097
|
const unmount = mount(
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
{ client },
|
|
1166
|
-
h(() => {
|
|
1098
|
+
<QueryClientProvider client={client}>
|
|
1099
|
+
{() => {
|
|
1167
1100
|
query = useSuspenseInfiniteQuery(() => ({
|
|
1168
1101
|
queryKey: ['sinf-1'],
|
|
1169
1102
|
queryFn: ({ pageParam }: { pageParam: number }) =>
|
|
@@ -1173,8 +1106,8 @@ describe('useSuspenseInfiniteQuery', () => {
|
|
|
1173
1106
|
lp < 1 ? lp + 1 : undefined,
|
|
1174
1107
|
}))
|
|
1175
1108
|
return null
|
|
1176
|
-
}
|
|
1177
|
-
|
|
1109
|
+
}}
|
|
1110
|
+
</QueryClientProvider>,
|
|
1178
1111
|
el,
|
|
1179
1112
|
)
|
|
1180
1113
|
|
|
@@ -1198,10 +1131,8 @@ describe('useSuspenseInfiniteQuery', () => {
|
|
|
1198
1131
|
const el = document.createElement('div')
|
|
1199
1132
|
document.body.appendChild(el)
|
|
1200
1133
|
const unmount = mount(
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
{ client },
|
|
1204
|
-
h(() => {
|
|
1134
|
+
<QueryClientProvider client={client}>
|
|
1135
|
+
{() => {
|
|
1205
1136
|
query = useSuspenseInfiniteQuery(() => ({
|
|
1206
1137
|
queryKey: ['sinf-pages'],
|
|
1207
1138
|
queryFn: ({ pageParam }: { pageParam: number }) =>
|
|
@@ -1213,8 +1144,8 @@ describe('useSuspenseInfiniteQuery', () => {
|
|
|
1213
1144
|
fp > 0 ? fp - 1 : undefined,
|
|
1214
1145
|
}))
|
|
1215
1146
|
return null
|
|
1216
|
-
}
|
|
1217
|
-
|
|
1147
|
+
}}
|
|
1148
|
+
</QueryClientProvider>,
|
|
1218
1149
|
el,
|
|
1219
1150
|
)
|
|
1220
1151
|
|
|
@@ -1236,10 +1167,8 @@ describe('useSuspenseInfiniteQuery', () => {
|
|
|
1236
1167
|
const el = document.createElement('div')
|
|
1237
1168
|
document.body.appendChild(el)
|
|
1238
1169
|
const unmount = mount(
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
{ client },
|
|
1242
|
-
h(() => {
|
|
1170
|
+
<QueryClientProvider client={client}>
|
|
1171
|
+
{() => {
|
|
1243
1172
|
query = useSuspenseInfiniteQuery(() => ({
|
|
1244
1173
|
queryKey: ['sinf-refetch'],
|
|
1245
1174
|
queryFn: () => {
|
|
@@ -1250,8 +1179,8 @@ describe('useSuspenseInfiniteQuery', () => {
|
|
|
1250
1179
|
getNextPageParam: () => undefined,
|
|
1251
1180
|
}))
|
|
1252
1181
|
return null
|
|
1253
|
-
}
|
|
1254
|
-
|
|
1182
|
+
}}
|
|
1183
|
+
</QueryClientProvider>,
|
|
1255
1184
|
el,
|
|
1256
1185
|
)
|
|
1257
1186
|
|
|
@@ -1269,10 +1198,8 @@ describe('useSuspenseInfiniteQuery', () => {
|
|
|
1269
1198
|
const el = document.createElement('div')
|
|
1270
1199
|
document.body.appendChild(el)
|
|
1271
1200
|
const unmount = mount(
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
{ client },
|
|
1275
|
-
h(() => {
|
|
1201
|
+
<QueryClientProvider client={client}>
|
|
1202
|
+
{() => {
|
|
1276
1203
|
query = useSuspenseInfiniteQuery(() => ({
|
|
1277
1204
|
queryKey: ['sinf-result'],
|
|
1278
1205
|
queryFn: () => Promise.resolve('v'),
|
|
@@ -1280,8 +1207,8 @@ describe('useSuspenseInfiniteQuery', () => {
|
|
|
1280
1207
|
getNextPageParam: () => undefined,
|
|
1281
1208
|
}))
|
|
1282
1209
|
return null
|
|
1283
|
-
}
|
|
1284
|
-
|
|
1210
|
+
}}
|
|
1211
|
+
</QueryClientProvider>,
|
|
1285
1212
|
el,
|
|
1286
1213
|
)
|
|
1287
1214
|
|
|
@@ -1297,10 +1224,8 @@ describe('useSuspenseInfiniteQuery', () => {
|
|
|
1297
1224
|
const el = document.createElement('div')
|
|
1298
1225
|
document.body.appendChild(el)
|
|
1299
1226
|
const unmount = mount(
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
{ client },
|
|
1303
|
-
h(() => {
|
|
1227
|
+
<QueryClientProvider client={client}>
|
|
1228
|
+
{() => {
|
|
1304
1229
|
query = useSuspenseInfiniteQuery(() => ({
|
|
1305
1230
|
queryKey: ['sinf-reactive', key()],
|
|
1306
1231
|
queryFn: () => Promise.resolve(`val-${key()}`),
|
|
@@ -1308,8 +1233,8 @@ describe('useSuspenseInfiniteQuery', () => {
|
|
|
1308
1233
|
getNextPageParam: () => undefined,
|
|
1309
1234
|
}))
|
|
1310
1235
|
return null
|
|
1311
|
-
}
|
|
1312
|
-
|
|
1236
|
+
}}
|
|
1237
|
+
</QueryClientProvider>,
|
|
1313
1238
|
el,
|
|
1314
1239
|
)
|
|
1315
1240
|
|
|
@@ -1336,17 +1261,15 @@ describe('useSuspenseQuery — additional', () => {
|
|
|
1336
1261
|
const el = document.createElement('div')
|
|
1337
1262
|
document.body.appendChild(el)
|
|
1338
1263
|
const unmount = mount(
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
{ client },
|
|
1342
|
-
h(() => {
|
|
1264
|
+
<QueryClientProvider client={client}>
|
|
1265
|
+
{() => {
|
|
1343
1266
|
query = useSuspenseQuery(() => ({
|
|
1344
1267
|
queryKey: ['sq-data-type'],
|
|
1345
1268
|
queryFn: () => Promise.resolve({ name: 'test' }),
|
|
1346
1269
|
}))
|
|
1347
1270
|
return null
|
|
1348
|
-
}
|
|
1349
|
-
|
|
1271
|
+
}}
|
|
1272
|
+
</QueryClientProvider>,
|
|
1350
1273
|
el,
|
|
1351
1274
|
)
|
|
1352
1275
|
|
|
@@ -1368,10 +1291,8 @@ describe('useSuspenseQuery — additional', () => {
|
|
|
1368
1291
|
const el = document.createElement('div')
|
|
1369
1292
|
document.body.appendChild(el)
|
|
1370
1293
|
const unmount = mount(
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
{ client },
|
|
1374
|
-
h(() => {
|
|
1294
|
+
<QueryClientProvider client={client}>
|
|
1295
|
+
{() => {
|
|
1375
1296
|
query = useSuspenseQuery(() => ({
|
|
1376
1297
|
queryKey: ['sq-refetch'],
|
|
1377
1298
|
queryFn: () => {
|
|
@@ -1380,8 +1301,8 @@ describe('useSuspenseQuery — additional', () => {
|
|
|
1380
1301
|
},
|
|
1381
1302
|
}))
|
|
1382
1303
|
return null
|
|
1383
|
-
}
|
|
1384
|
-
|
|
1304
|
+
}}
|
|
1305
|
+
</QueryClientProvider>,
|
|
1385
1306
|
el,
|
|
1386
1307
|
)
|
|
1387
1308
|
|
|
@@ -1400,17 +1321,15 @@ describe('useSuspenseQuery — additional', () => {
|
|
|
1400
1321
|
const el = document.createElement('div')
|
|
1401
1322
|
document.body.appendChild(el)
|
|
1402
1323
|
const unmount = mount(
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
{ client },
|
|
1406
|
-
h(() => {
|
|
1324
|
+
<QueryClientProvider client={client}>
|
|
1325
|
+
{() => {
|
|
1407
1326
|
query = useSuspenseQuery(() => ({
|
|
1408
1327
|
queryKey: ['sq-reactive', key()],
|
|
1409
1328
|
queryFn: () => Promise.resolve(`data-${key()}`),
|
|
1410
1329
|
}))
|
|
1411
1330
|
return null
|
|
1412
|
-
}
|
|
1413
|
-
|
|
1331
|
+
}}
|
|
1332
|
+
</QueryClientProvider>,
|
|
1414
1333
|
el,
|
|
1415
1334
|
)
|
|
1416
1335
|
|
|
@@ -1432,17 +1351,15 @@ describe('useSuspenseQuery — additional', () => {
|
|
|
1432
1351
|
|
|
1433
1352
|
let query: ReturnType<typeof useSuspenseQuery> | undefined
|
|
1434
1353
|
const unmount = mount(
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
{ client },
|
|
1438
|
-
h(() => {
|
|
1354
|
+
<QueryClientProvider client={client}>
|
|
1355
|
+
{() => {
|
|
1439
1356
|
query = useSuspenseQuery(() => ({
|
|
1440
1357
|
queryKey: ['sq-rethrow2'],
|
|
1441
1358
|
queryFn: () => promise,
|
|
1442
1359
|
}))
|
|
1443
1360
|
return null
|
|
1444
|
-
}
|
|
1445
|
-
|
|
1361
|
+
}}
|
|
1362
|
+
</QueryClientProvider>,
|
|
1446
1363
|
el,
|
|
1447
1364
|
)
|
|
1448
1365
|
|
|
@@ -1462,10 +1379,8 @@ describe('useSuspenseQuery — additional', () => {
|
|
|
1462
1379
|
const el = document.createElement('div')
|
|
1463
1380
|
document.body.appendChild(el)
|
|
1464
1381
|
const unmount = mount(
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
{ client },
|
|
1468
|
-
h(() => {
|
|
1382
|
+
<QueryClientProvider client={client}>
|
|
1383
|
+
{() => {
|
|
1469
1384
|
query = useSuspenseQuery(() => ({
|
|
1470
1385
|
queryKey: ['sq-fn-fallback'],
|
|
1471
1386
|
queryFn: () =>
|
|
@@ -1473,13 +1388,13 @@ describe('useSuspenseQuery — additional', () => {
|
|
|
1473
1388
|
/* never resolves */
|
|
1474
1389
|
}),
|
|
1475
1390
|
}))
|
|
1476
|
-
return
|
|
1477
|
-
QuerySuspense
|
|
1478
|
-
|
|
1479
|
-
|
|
1391
|
+
return (
|
|
1392
|
+
<QuerySuspense query={query!} fallback={() => 'loading fn'}>
|
|
1393
|
+
{() => null}
|
|
1394
|
+
</QuerySuspense>
|
|
1480
1395
|
)
|
|
1481
|
-
}
|
|
1482
|
-
|
|
1396
|
+
}}
|
|
1397
|
+
</QueryClientProvider>,
|
|
1483
1398
|
el,
|
|
1484
1399
|
)
|
|
1485
1400
|
|
|
@@ -1501,14 +1416,12 @@ describe('QueryClientProvider — VNode children branch', () => {
|
|
|
1501
1416
|
document.body.appendChild(el)
|
|
1502
1417
|
// Pass children as a direct VNode, not wrapped in a function
|
|
1503
1418
|
const unmount = mount(
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
{ client },
|
|
1507
|
-
h(() => {
|
|
1419
|
+
<QueryClientProvider client={client}>
|
|
1420
|
+
{() => {
|
|
1508
1421
|
received = useQueryClient()
|
|
1509
1422
|
return null
|
|
1510
|
-
}
|
|
1511
|
-
|
|
1423
|
+
}}
|
|
1424
|
+
</QueryClientProvider>,
|
|
1512
1425
|
el,
|
|
1513
1426
|
)
|
|
1514
1427
|
expect(received).toBe(client)
|
|
@@ -1522,12 +1435,14 @@ describe('QueryClientProvider — VNode children branch', () => {
|
|
|
1522
1435
|
const el = document.createElement('div')
|
|
1523
1436
|
document.body.appendChild(el)
|
|
1524
1437
|
const unmount = mount(
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1438
|
+
<QueryClientProvider client={client}>
|
|
1439
|
+
{() => {
|
|
1440
|
+
return (() => {
|
|
1441
|
+
received = useQueryClient()
|
|
1442
|
+
return null
|
|
1443
|
+
})()
|
|
1444
|
+
}}
|
|
1445
|
+
</QueryClientProvider>,
|
|
1531
1446
|
el,
|
|
1532
1447
|
)
|
|
1533
1448
|
expect(received).toBe(client)
|
|
@@ -1547,16 +1462,14 @@ describe('useMutation — mutateAsync', () => {
|
|
|
1547
1462
|
const el = document.createElement('div')
|
|
1548
1463
|
document.body.appendChild(el)
|
|
1549
1464
|
const unmount = mount(
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
{ client },
|
|
1553
|
-
h(() => {
|
|
1465
|
+
<QueryClientProvider client={client}>
|
|
1466
|
+
{() => {
|
|
1554
1467
|
mut = useMutation<string, Error, string>({
|
|
1555
1468
|
mutationFn: async (input: string) => `async-result:${input}`,
|
|
1556
1469
|
})
|
|
1557
1470
|
return null
|
|
1558
|
-
}
|
|
1559
|
-
|
|
1471
|
+
}}
|
|
1472
|
+
</QueryClientProvider>,
|
|
1560
1473
|
el,
|
|
1561
1474
|
)
|
|
1562
1475
|
|
|
@@ -1573,18 +1486,16 @@ describe('useMutation — mutateAsync', () => {
|
|
|
1573
1486
|
const el = document.createElement('div')
|
|
1574
1487
|
document.body.appendChild(el)
|
|
1575
1488
|
const unmount = mount(
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
{ client },
|
|
1579
|
-
h(() => {
|
|
1489
|
+
<QueryClientProvider client={client}>
|
|
1490
|
+
{() => {
|
|
1580
1491
|
mut = useMutation<string, Error, void>({
|
|
1581
1492
|
mutationFn: async () => {
|
|
1582
1493
|
throw new Error('async-fail')
|
|
1583
1494
|
},
|
|
1584
1495
|
})
|
|
1585
1496
|
return null
|
|
1586
|
-
}
|
|
1587
|
-
|
|
1497
|
+
}}
|
|
1498
|
+
</QueryClientProvider>,
|
|
1588
1499
|
el,
|
|
1589
1500
|
)
|
|
1590
1501
|
|
|
@@ -1609,10 +1520,8 @@ describe('useQuery — refetch', () => {
|
|
|
1609
1520
|
const el = document.createElement('div')
|
|
1610
1521
|
document.body.appendChild(el)
|
|
1611
1522
|
const unmount = mount(
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
{ client },
|
|
1615
|
-
h(() => {
|
|
1523
|
+
<QueryClientProvider client={client}>
|
|
1524
|
+
{() => {
|
|
1616
1525
|
query = useQuery(() => ({
|
|
1617
1526
|
queryKey: ['refetch-test'],
|
|
1618
1527
|
queryFn: async () => {
|
|
@@ -1621,8 +1530,8 @@ describe('useQuery — refetch', () => {
|
|
|
1621
1530
|
},
|
|
1622
1531
|
}))
|
|
1623
1532
|
return null
|
|
1624
|
-
}
|
|
1625
|
-
|
|
1533
|
+
}}
|
|
1534
|
+
</QueryClientProvider>,
|
|
1626
1535
|
el,
|
|
1627
1536
|
)
|
|
1628
1537
|
|
|
@@ -1648,19 +1557,15 @@ describe('QueryErrorResetBoundary — VNode children branch', () => {
|
|
|
1648
1557
|
document.body.appendChild(el)
|
|
1649
1558
|
// Pass children as a direct VNode, not a function
|
|
1650
1559
|
const unmount = mount(
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
h(
|
|
1655
|
-
QueryErrorResetBoundary,
|
|
1656
|
-
null,
|
|
1657
|
-
h(() => {
|
|
1560
|
+
<QueryClientProvider client={client}>
|
|
1561
|
+
<QueryErrorResetBoundary>
|
|
1562
|
+
{() => {
|
|
1658
1563
|
const { reset } = useQueryErrorResetBoundary()
|
|
1659
1564
|
resetFn = reset
|
|
1660
1565
|
return null
|
|
1661
|
-
}
|
|
1662
|
-
|
|
1663
|
-
|
|
1566
|
+
}}
|
|
1567
|
+
</QueryErrorResetBoundary>
|
|
1568
|
+
</QueryClientProvider>,
|
|
1664
1569
|
el,
|
|
1665
1570
|
)
|
|
1666
1571
|
|
|
@@ -1687,22 +1592,20 @@ describe('useSuspenseQuery — error without handler (QuerySuspense throw branch
|
|
|
1687
1592
|
let query: ReturnType<typeof useSuspenseQuery> | undefined
|
|
1688
1593
|
|
|
1689
1594
|
const unmount = mount(
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
{ client },
|
|
1693
|
-
h(() => {
|
|
1595
|
+
<QueryClientProvider client={client}>
|
|
1596
|
+
{() => {
|
|
1694
1597
|
query = useSuspenseQuery(() => ({
|
|
1695
1598
|
queryKey: ['sq-throw-no-handler'],
|
|
1696
1599
|
queryFn: () => promise,
|
|
1697
1600
|
}))
|
|
1698
1601
|
// QuerySuspense with NO error handler — should throw
|
|
1699
|
-
return
|
|
1700
|
-
QuerySuspense
|
|
1701
|
-
|
|
1702
|
-
|
|
1602
|
+
return (
|
|
1603
|
+
<QuerySuspense query={query!} fallback="loading">
|
|
1604
|
+
{() => null}
|
|
1605
|
+
</QuerySuspense>
|
|
1703
1606
|
)
|
|
1704
|
-
}
|
|
1705
|
-
|
|
1607
|
+
}}
|
|
1608
|
+
</QueryClientProvider>,
|
|
1706
1609
|
el,
|
|
1707
1610
|
)
|
|
1708
1611
|
|
|
@@ -1732,17 +1635,15 @@ describe('useSuspenseQuery — error without handler (QuerySuspense throw branch
|
|
|
1732
1635
|
let query: ReturnType<typeof useSuspenseQuery> | undefined
|
|
1733
1636
|
|
|
1734
1637
|
const unmount = mount(
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
{ client },
|
|
1738
|
-
h(() => {
|
|
1638
|
+
<QueryClientProvider client={client}>
|
|
1639
|
+
{() => {
|
|
1739
1640
|
query = useSuspenseQuery(() => ({
|
|
1740
1641
|
queryKey: ['sq-rethrow-direct'],
|
|
1741
1642
|
queryFn: () => promise,
|
|
1742
1643
|
}))
|
|
1743
1644
|
return null
|
|
1744
|
-
}
|
|
1745
|
-
|
|
1645
|
+
}}
|
|
1646
|
+
</QueryClientProvider>,
|
|
1746
1647
|
el,
|
|
1747
1648
|
)
|
|
1748
1649
|
|