@tanstack/solid-query 5.0.0-beta.15 → 5.0.0-beta.18

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanstack/solid-query",
3
- "version": "5.0.0-beta.15",
3
+ "version": "5.0.0-beta.18",
4
4
  "description": "Primitives for managing, caching and syncing asynchronous and remote data in Solid",
5
5
  "author": "tannerlinsley",
6
6
  "license": "MIT",
@@ -48,7 +48,7 @@
48
48
  ],
49
49
  "dependencies": {
50
50
  "solid-js": "^1.7.8",
51
- "@tanstack/query-core": "5.0.0-beta.15"
51
+ "@tanstack/query-core": "5.0.0-beta.18"
52
52
  },
53
53
  "devDependencies": {
54
54
  "tsup-preset-solid": "^2.0.1",
@@ -69,7 +69,7 @@ describe('useInfiniteQuery', () => {
69
69
  queryKey: key,
70
70
  queryFn: ({ pageParam }) => Number(pageParam),
71
71
  getNextPageParam: (lastPage) => lastPage + 1,
72
- defaultPageParam: 0,
72
+ initialPageParam: 0,
73
73
  }))
74
74
  createRenderEffect(() => {
75
75
  states.push({ ...state })
@@ -170,7 +170,7 @@ describe('useInfiniteQuery', () => {
170
170
 
171
171
  retry: 1,
172
172
  retryDelay: 10,
173
- defaultPageParam: start,
173
+ initialPageParam: start,
174
174
  getNextPageParam: (lastPage) => lastPage + 1,
175
175
  }))
176
176
 
@@ -213,7 +213,7 @@ describe('useInfiniteQuery', () => {
213
213
  },
214
214
 
215
215
  getNextPageParam: () => 1,
216
- defaultPageParam: 0,
216
+ initialPageParam: 0,
217
217
  placeholderData: keepPreviousData,
218
218
  notifyOnChangeProps: 'all',
219
219
  }))
@@ -315,7 +315,7 @@ describe('useInfiniteQuery', () => {
315
315
  pageParams: data.pageParams,
316
316
  }),
317
317
  getNextPageParam: () => undefined,
318
- defaultPageParam: 0,
318
+ initialPageParam: 0,
319
319
  }))
320
320
  createRenderEffect(() => {
321
321
  states.push({ ...state })
@@ -361,7 +361,7 @@ describe('useInfiniteQuery', () => {
361
361
  }
362
362
  },
363
363
  getNextPageParam: () => undefined,
364
- defaultPageParam: 0,
364
+ initialPageParam: 0,
365
365
  }))
366
366
  createRenderEffect(() => {
367
367
  states.push({ ...state })
@@ -408,7 +408,7 @@ describe('useInfiniteQuery', () => {
408
408
  }),
409
409
  notifyOnChangeProps: 'all',
410
410
  getNextPageParam: () => 1,
411
- defaultPageParam: 0,
411
+ initialPageParam: 0,
412
412
  }))
413
413
 
414
414
  createRenderEffect(
@@ -479,7 +479,7 @@ describe('useInfiniteQuery', () => {
479
479
  },
480
480
  getNextPageParam: (lastPage) => lastPage + 1,
481
481
  getPreviousPageParam: (firstPage) => firstPage - 1,
482
- defaultPageParam: start,
482
+ initialPageParam: start,
483
483
  notifyOnChangeProps: 'all',
484
484
  }))
485
485
 
@@ -567,7 +567,7 @@ describe('useInfiniteQuery', () => {
567
567
 
568
568
  getPreviousPageParam: (firstPage) => firstPage - 1,
569
569
  getNextPageParam: (lastPage) => lastPage + 1,
570
- defaultPageParam: 10,
570
+ initialPageParam: 10,
571
571
  notifyOnChangeProps: 'all',
572
572
  }))
573
573
 
@@ -688,7 +688,7 @@ describe('useInfiniteQuery', () => {
688
688
  },
689
689
 
690
690
  getNextPageParam: (lastPage) => lastPage + 1,
691
- defaultPageParam: start,
691
+ initialPageParam: start,
692
692
  notifyOnChangeProps: 'all',
693
693
  }))
694
694
 
@@ -786,7 +786,7 @@ describe('useInfiniteQuery', () => {
786
786
  queryKey: key,
787
787
  queryFn: fetchPage,
788
788
  getNextPageParam: (lastPage) => lastPage + 1,
789
- defaultPageParam: start,
789
+ initialPageParam: start,
790
790
  }))
791
791
 
792
792
  createEffect(() => {
@@ -868,7 +868,7 @@ describe('useInfiniteQuery', () => {
868
868
  queryKey: key,
869
869
  queryFn: fetchPage,
870
870
  getNextPageParam: (lastPage) => lastPage + 1,
871
- defaultPageParam: start,
871
+ initialPageParam: start,
872
872
  }))
873
873
 
874
874
  createEffect(() => {
@@ -930,7 +930,7 @@ describe('useInfiniteQuery', () => {
930
930
  },
931
931
 
932
932
  getNextPageParam: (lastPage) => lastPage + 1,
933
- defaultPageParam: start,
933
+ initialPageParam: start,
934
934
  notifyOnChangeProps: 'all',
935
935
  }))
936
936
 
@@ -992,7 +992,7 @@ describe('useInfiniteQuery', () => {
992
992
  getNextPageParam: (_, allPages) => {
993
993
  return allPages.length === 4 ? undefined : allPages.length
994
994
  },
995
- defaultPageParam: 0,
995
+ initialPageParam: 0,
996
996
  }))
997
997
 
998
998
  return null
@@ -1043,7 +1043,7 @@ describe('useInfiniteQuery', () => {
1043
1043
 
1044
1044
  getNextPageParam: (lastPage) => lastPage + 1,
1045
1045
  notifyOnChangeProps: 'all',
1046
- defaultPageParam: firstPage(),
1046
+ initialPageParam: firstPage(),
1047
1047
  }))
1048
1048
 
1049
1049
  createRenderEffect(() => {
@@ -1136,7 +1136,7 @@ describe('useInfiniteQuery', () => {
1136
1136
 
1137
1137
  initialData: { pages: [1], pageParams: [1] },
1138
1138
  getNextPageParam: (lastPage) => lastPage + 1,
1139
- defaultPageParam: 0,
1139
+ initialPageParam: 0,
1140
1140
  notifyOnChangeProps: 'all',
1141
1141
  }))
1142
1142
 
@@ -1207,7 +1207,7 @@ describe('useInfiniteQuery', () => {
1207
1207
  const state = createInfiniteQuery(() => ({
1208
1208
  queryKey: key,
1209
1209
  queryFn: ({ pageParam }) => Number(pageParam),
1210
- defaultPageParam: 1,
1210
+ initialPageParam: 1,
1211
1211
  getNextPageParam: () => undefined,
1212
1212
  }))
1213
1213
 
@@ -1251,7 +1251,7 @@ describe('useInfiniteQuery', () => {
1251
1251
  const state = createInfiniteQuery(() => ({
1252
1252
  queryKey: key,
1253
1253
  queryFn: ({ pageParam }): number => pageParam,
1254
- defaultPageParam: 10,
1254
+ initialPageParam: 10,
1255
1255
  initialData: { pages: [10], pageParams: [10] },
1256
1256
  getNextPageParam: (lastPage) => (lastPage === 10 ? 11 : undefined),
1257
1257
  }))
@@ -1295,7 +1295,7 @@ describe('useInfiniteQuery', () => {
1295
1295
  const state = createInfiniteQuery(() => ({
1296
1296
  queryKey: key,
1297
1297
  queryFn: ({ pageParam }): number => pageParam,
1298
- defaultPageParam: 10,
1298
+ initialPageParam: 10,
1299
1299
  initialData: { pages: [10], pageParams: [10] },
1300
1300
  getNextPageParam: () => undefined,
1301
1301
  }))
@@ -1339,7 +1339,7 @@ describe('useInfiniteQuery', () => {
1339
1339
  const state = createInfiniteQuery(() => ({
1340
1340
  queryKey: key,
1341
1341
  queryFn: ({ pageParam }) => Number(pageParam),
1342
- defaultPageParam: 1,
1342
+ initialPageParam: 1,
1343
1343
  getNextPageParam: (lastPage) => (lastPage === 1 ? 2 : undefined),
1344
1344
  select: (data) => ({
1345
1345
  pages: data.pages.map((x) => x.toString()),
@@ -1402,7 +1402,7 @@ describe('useInfiniteQuery', () => {
1402
1402
  queryKey: key,
1403
1403
  queryFn: ({ pageParam }) =>
1404
1404
  fetchItemsWithLimit(pageParam, fetchCountRef++),
1405
- defaultPageParam: 0,
1405
+ initialPageParam: 0,
1406
1406
  getNextPageParam: (lastPage) => lastPage.nextId,
1407
1407
  }))
1408
1408
 
@@ -1536,7 +1536,7 @@ describe('useInfiniteQuery', () => {
1536
1536
  fetchCountRef++,
1537
1537
  pageParam === MAX || (pageParam === MAX - 1 && isRemovedLastPage()),
1538
1538
  ),
1539
- defaultPageParam: 0,
1539
+ initialPageParam: 0,
1540
1540
  getNextPageParam: (lastPage) => lastPage.nextId,
1541
1541
  }))
1542
1542
 
@@ -1670,7 +1670,7 @@ describe('useInfiniteQuery', () => {
1670
1670
  queryKey: key,
1671
1671
  queryFn,
1672
1672
  getNextPageParam: () => undefined,
1673
- defaultPageParam: 0,
1673
+ initialPageParam: 0,
1674
1674
  }))
1675
1675
  return (
1676
1676
  <div>
@@ -1704,7 +1704,7 @@ describe('useInfiniteQuery', () => {
1704
1704
  queryKey: key,
1705
1705
  queryFn,
1706
1706
  getNextPageParam: () => undefined,
1707
- defaultPageParam: 0,
1707
+ initialPageParam: 0,
1708
1708
  }),
1709
1709
  () => queryClient,
1710
1710
  )
@@ -64,6 +64,10 @@ describe('createMutation', () => {
64
64
  })
65
65
 
66
66
  it('should be able to reset `error`', async () => {
67
+ const consoleMock = vi
68
+ .spyOn(console, 'error')
69
+ .mockImplementation(() => undefined)
70
+
67
71
  function Page() {
68
72
  const mutation = createMutation<string, Error>(() => ({
69
73
  mutationFn: () => {
@@ -105,6 +109,8 @@ describe('createMutation', () => {
105
109
  await waitFor(() => {
106
110
  expect(screen.queryByRole('heading')).toBeNull()
107
111
  })
112
+
113
+ consoleMock.mockRestore()
108
114
  })
109
115
 
110
116
  it('should be able to call `onSuccess` and `onSettled` after each successful mutate', async () => {
@@ -781,6 +787,10 @@ describe('createMutation', () => {
781
787
  })
782
788
 
783
789
  it('should be able to throw an error when throwOnError is set to true', async () => {
790
+ const consoleMock = vi
791
+ .spyOn(console, 'error')
792
+ .mockImplementation(() => undefined)
793
+
784
794
  function Page() {
785
795
  const mutation = createMutation<string, Error>(() => ({
786
796
  mutationFn: () => {
@@ -817,9 +827,15 @@ describe('createMutation', () => {
817
827
  await waitFor(() => {
818
828
  expect(screen.queryByText('error')).not.toBeNull()
819
829
  })
830
+
831
+ consoleMock.mockRestore()
820
832
  })
821
833
 
822
834
  it('should be able to throw an error when throwOnError is a function that returns true', async () => {
835
+ const consoleMock = vi
836
+ .spyOn(console, 'error')
837
+ .mockImplementation(() => undefined)
838
+
823
839
  let boundary = false
824
840
  function Page() {
825
841
  const mutation = createMutation<string, Error>(() => ({
@@ -867,6 +883,8 @@ describe('createMutation', () => {
867
883
  await waitFor(() => {
868
884
  expect(screen.queryByText('error boundary')).not.toBeNull()
869
885
  })
886
+
887
+ consoleMock.mockRestore()
870
888
  })
871
889
 
872
890
  it('should pass meta to mutation', async () => {
@@ -2446,6 +2446,10 @@ describe('createQuery', () => {
2446
2446
  it('should set status to error if queryFn throws', async () => {
2447
2447
  const key = queryKey()
2448
2448
 
2449
+ const consoleMock = vi
2450
+ .spyOn(console, 'error')
2451
+ .mockImplementation(() => undefined)
2452
+
2449
2453
  function Page() {
2450
2454
  const state = createQuery(() => ({
2451
2455
  queryKey: key,
@@ -2471,11 +2475,17 @@ describe('createQuery', () => {
2471
2475
 
2472
2476
  await waitFor(() => screen.getByText('error'))
2473
2477
  await waitFor(() => screen.getByText('Error test jaylen'))
2478
+
2479
+ consoleMock.mockRestore()
2474
2480
  })
2475
2481
 
2476
2482
  it('should throw error if queryFn throws and throwOnError is in use', async () => {
2477
2483
  const key = queryKey()
2478
2484
 
2485
+ const consoleMock = vi
2486
+ .spyOn(console, 'error')
2487
+ .mockImplementation(() => undefined)
2488
+
2479
2489
  function Page() {
2480
2490
  const state = createQuery(() => ({
2481
2491
  queryKey: key,
@@ -2501,6 +2511,8 @@ describe('createQuery', () => {
2501
2511
  ))
2502
2512
 
2503
2513
  await waitFor(() => screen.getByText('error boundary'))
2514
+
2515
+ consoleMock.mockRestore()
2504
2516
  })
2505
2517
 
2506
2518
  it('should update with data if we observe no properties and throwOnError', async () => {
@@ -94,7 +94,7 @@ describe("useQuery's in Suspense mode", () => {
94
94
  await sleep(10)
95
95
  return Number(pageParam * multiplier())
96
96
  },
97
- defaultPageParam: 1,
97
+ initialPageParam: 1,
98
98
  suspense: true,
99
99
  getNextPageParam: (lastPage) => lastPage + 1,
100
100
  }))
@@ -453,6 +453,10 @@ describe("useQuery's in Suspense mode", () => {
453
453
  it('should throw errors to the error boundary by default', async () => {
454
454
  const key = queryKey()
455
455
 
456
+ const consoleMock = vi
457
+ .spyOn(console, 'error')
458
+ .mockImplementation(() => undefined)
459
+
456
460
  function Page() {
457
461
  const state = createQuery(() => ({
458
462
  queryKey: key,
@@ -497,6 +501,8 @@ describe("useQuery's in Suspense mode", () => {
497
501
 
498
502
  await waitFor(() => screen.getByText('Loading...'))
499
503
  await waitFor(() => screen.getByText('error boundary'))
504
+
505
+ consoleMock.mockRestore()
500
506
  })
501
507
 
502
508
  it('should not throw errors to the error boundary when throwOnError: false', async () => {
@@ -551,6 +557,10 @@ describe("useQuery's in Suspense mode", () => {
551
557
  it('should throw errors to the error boundary when a throwOnError function returns true', async () => {
552
558
  const key = queryKey()
553
559
 
560
+ const consoleMock = vi
561
+ .spyOn(console, 'error')
562
+ .mockImplementation(() => undefined)
563
+
554
564
  function Page() {
555
565
  const state = createQuery(() => ({
556
566
  queryKey: key,
@@ -595,6 +605,8 @@ describe("useQuery's in Suspense mode", () => {
595
605
 
596
606
  await waitFor(() => screen.getByText('Loading...'))
597
607
  await waitFor(() => screen.getByText('error boundary'))
608
+
609
+ consoleMock.mockRestore()
598
610
  })
599
611
 
600
612
  it('should not throw errors to the error boundary when a throwOnError function returns false', async () => {
@@ -696,6 +708,10 @@ describe("useQuery's in Suspense mode", () => {
696
708
  it('should error catched in error boundary without infinite loop', async () => {
697
709
  const key = queryKey()
698
710
 
711
+ const consoleMock = vi
712
+ .spyOn(console, 'error')
713
+ .mockImplementation(() => undefined)
714
+
699
715
  let succeed = true
700
716
 
701
717
  function Page() {
@@ -756,11 +772,17 @@ describe("useQuery's in Suspense mode", () => {
756
772
  fireEvent.click(screen.getByLabelText('fail'))
757
773
  // render error boundary fallback (error boundary)
758
774
  await waitFor(() => screen.getByText('error boundary'))
775
+
776
+ consoleMock.mockRestore()
759
777
  })
760
778
 
761
779
  it('should error catched in error boundary without infinite loop when query keys changed', async () => {
762
780
  let succeed = true
763
781
 
782
+ const consoleMock = vi
783
+ .spyOn(console, 'error')
784
+ .mockImplementation(() => undefined)
785
+
764
786
  function Page() {
765
787
  const [key, setKey] = createSignal(0)
766
788
 
@@ -814,9 +836,15 @@ describe("useQuery's in Suspense mode", () => {
814
836
  fireEvent.click(screen.getByLabelText('fail'))
815
837
  // render error boundary fallback (error boundary)
816
838
  await waitFor(() => screen.getByText('error boundary'))
839
+
840
+ consoleMock.mockRestore()
817
841
  })
818
842
 
819
843
  it('should error catched in error boundary without infinite loop when enabled changed', async () => {
844
+ const consoleMock = vi
845
+ .spyOn(console, 'error')
846
+ .mockImplementation(() => undefined)
847
+
820
848
  function Page() {
821
849
  const queryKeys = '1'
822
850
  const [enabled, setEnabled] = createSignal(false)
@@ -874,6 +902,8 @@ describe("useQuery's in Suspense mode", () => {
874
902
 
875
903
  // render error boundary fallback (error boundary)
876
904
  await waitFor(() => screen.getByText('error boundary'))
905
+
906
+ consoleMock.mockRestore()
877
907
  })
878
908
 
879
909
  it('should render the correct amount of times in Suspense mode when gcTime is set to 0', async () => {