@tanstack/solid-query 4.7.1 → 4.8.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanstack/solid-query",
3
- "version": "4.7.1",
3
+ "version": "4.8.0",
4
4
  "description": "Primitives for managing, caching and syncing asynchronous and remote data in Solid",
5
5
  "author": "tannerlinsley",
6
6
  "license": "MIT",
@@ -26,12 +26,6 @@
26
26
  "./package.json": "./package.json"
27
27
  },
28
28
  "sideEffects": false,
29
- "scripts": {
30
- "clean": "rm -rf ./build",
31
- "test:eslint": "../../node_modules/.bin/eslint --ext .ts,.tsx ./src",
32
- "test:jest": "../../node_modules/.bin/jest --config jest.config.js",
33
- "test:jest:dev": "yarn test:jest --watch"
34
- },
35
29
  "files": [
36
30
  "build/lib/*",
37
31
  "build/umd/*",
@@ -43,10 +37,16 @@
43
37
  "jscodeshift": "^0.13.1"
44
38
  },
45
39
  "dependencies": {
46
- "@tanstack/query-core": "4.7.1"
40
+ "@tanstack/query-core": "4.8.0"
47
41
  },
48
42
  "peerDependencies": {
49
43
  "solid-js": "^1.5.4"
50
44
  },
51
- "peerDependenciesMeta": {}
52
- }
45
+ "peerDependenciesMeta": {},
46
+ "scripts": {
47
+ "clean": "rm -rf ./build",
48
+ "test:eslint": "../../node_modules/.bin/eslint --ext .ts,.tsx ./src",
49
+ "test:jest": "../../node_modules/.bin/jest --config jest.config.js",
50
+ "test:jest:dev": "pnpm test:jest --watch"
51
+ }
52
+ }
@@ -93,6 +93,7 @@ describe('useInfiniteQuery', () => {
93
93
  isFetchingNextPage: false,
94
94
  isFetchingPreviousPage: false,
95
95
  isLoading: true,
96
+ isInitialLoading: true,
96
97
  isLoadingError: false,
97
98
  isPlaceholderData: false,
98
99
  isPreviousData: false,
@@ -125,6 +126,7 @@ describe('useInfiniteQuery', () => {
125
126
  isFetchingNextPage: false,
126
127
  isFetchingPreviousPage: false,
127
128
  isLoading: false,
129
+ isInitialLoading: false,
128
130
  isLoadingError: false,
129
131
  isPlaceholderData: false,
130
132
  isPreviousData: false,
@@ -938,34 +940,28 @@ describe('useInfiniteQuery', () => {
938
940
  const firstCtx = fetchPage.mock.calls[callIndex]![0]
939
941
  expect(firstCtx.pageParam).toBeUndefined()
940
942
  expect(firstCtx.queryKey).toEqual(key())
941
- if (typeof AbortSignal === 'function') {
942
- expect(firstCtx.signal).toBeInstanceOf(AbortSignal)
943
- expect(firstCtx.signal?.aborted).toBe(false)
944
- expect(onAborts[callIndex]).not.toHaveBeenCalled()
945
- expect(abortListeners[callIndex]).not.toHaveBeenCalled()
946
- }
943
+ expect(firstCtx.signal).toBeInstanceOf(AbortSignal)
944
+ expect(firstCtx.signal?.aborted).toBe(false)
945
+ expect(onAborts[callIndex]).not.toHaveBeenCalled()
946
+ expect(abortListeners[callIndex]).not.toHaveBeenCalled()
947
947
 
948
948
  callIndex = 1
949
949
  const secondCtx = fetchPage.mock.calls[callIndex]![0]
950
950
  expect(secondCtx.pageParam).toBe(11)
951
951
  expect(secondCtx.queryKey).toEqual(key())
952
- if (typeof AbortSignal === 'function') {
953
- expect(secondCtx.signal).toBeInstanceOf(AbortSignal)
954
- expect(secondCtx.signal?.aborted).toBe(true)
955
- expect(onAborts[callIndex]).toHaveBeenCalledTimes(1)
956
- expect(abortListeners[callIndex]).toHaveBeenCalledTimes(1)
957
- }
952
+ expect(secondCtx.signal).toBeInstanceOf(AbortSignal)
953
+ expect(secondCtx.signal?.aborted).toBe(true)
954
+ expect(onAborts[callIndex]).toHaveBeenCalledTimes(1)
955
+ expect(abortListeners[callIndex]).toHaveBeenCalledTimes(1)
958
956
 
959
957
  callIndex = 2
960
958
  const thirdCtx = fetchPage.mock.calls[callIndex]![0]
961
959
  expect(thirdCtx.pageParam).toBe(11)
962
960
  expect(thirdCtx.queryKey).toEqual(key())
963
- if (typeof AbortSignal === 'function') {
964
- expect(thirdCtx.signal).toBeInstanceOf(AbortSignal)
965
- expect(thirdCtx.signal?.aborted).toBe(false)
966
- expect(onAborts[callIndex]).not.toHaveBeenCalled()
967
- expect(abortListeners[callIndex]).not.toHaveBeenCalled()
968
- }
961
+ expect(thirdCtx.signal).toBeInstanceOf(AbortSignal)
962
+ expect(thirdCtx.signal?.aborted).toBe(false)
963
+ expect(onAborts[callIndex]).not.toHaveBeenCalled()
964
+ expect(abortListeners[callIndex]).not.toHaveBeenCalled()
969
965
  })
970
966
 
971
967
  it('should not cancel an ongoing fetchNextPage request when another fetchNextPage is invoked if `cancelRefetch: false` is used ', async () => {
@@ -1024,23 +1020,19 @@ describe('useInfiniteQuery', () => {
1024
1020
  const firstCtx = fetchPage.mock.calls[callIndex]![0]
1025
1021
  expect(firstCtx.pageParam).toBeUndefined()
1026
1022
  expect(firstCtx.queryKey).toEqual(key())
1027
- if (typeof AbortSignal === 'function') {
1028
- expect(firstCtx.signal).toBeInstanceOf(AbortSignal)
1029
- expect(firstCtx.signal?.aborted).toBe(false)
1030
- expect(onAborts[callIndex]).not.toHaveBeenCalled()
1031
- expect(abortListeners[callIndex]).not.toHaveBeenCalled()
1032
- }
1023
+ expect(firstCtx.signal).toBeInstanceOf(AbortSignal)
1024
+ expect(firstCtx.signal?.aborted).toBe(false)
1025
+ expect(onAborts[callIndex]).not.toHaveBeenCalled()
1026
+ expect(abortListeners[callIndex]).not.toHaveBeenCalled()
1033
1027
 
1034
1028
  callIndex = 1
1035
1029
  const secondCtx = fetchPage.mock.calls[callIndex]![0]
1036
1030
  expect(secondCtx.pageParam).toBe(11)
1037
1031
  expect(secondCtx.queryKey).toEqual(key())
1038
- if (typeof AbortSignal === 'function') {
1039
- expect(secondCtx.signal).toBeInstanceOf(AbortSignal)
1040
- expect(secondCtx.signal?.aborted).toBe(false)
1041
- expect(onAborts[callIndex]).not.toHaveBeenCalled()
1042
- expect(abortListeners[callIndex]).not.toHaveBeenCalled()
1043
- }
1032
+ expect(secondCtx.signal).toBeInstanceOf(AbortSignal)
1033
+ expect(secondCtx.signal?.aborted).toBe(false)
1034
+ expect(onAborts[callIndex]).not.toHaveBeenCalled()
1035
+ expect(abortListeners[callIndex]).not.toHaveBeenCalled()
1044
1036
  })
1045
1037
 
1046
1038
  it('should keep fetching first page when not loaded yet and triggering fetch more', async () => {
@@ -1145,22 +1137,12 @@ describe('useInfiniteQuery', () => {
1145
1137
 
1146
1138
  await sleep(300)
1147
1139
 
1148
- if (typeof AbortSignal === 'function') {
1149
- expect(fetches).toBe(2)
1150
- expect(queryClient.getQueryState(key())).toMatchObject({
1151
- data: initialData,
1152
- status: 'success',
1153
- error: null,
1154
- })
1155
- } else {
1156
- // if AbortSignal is not consumed, fetches should not abort
1157
- expect(fetches).toBe(4)
1158
- expect(queryClient.getQueryState(key())).toMatchObject({
1159
- data: { pages: [0, 10, 20, 30], pageParams: [0, 1, 2, 3] },
1160
- status: 'success',
1161
- error: null,
1162
- })
1163
- }
1140
+ expect(fetches).toBe(2)
1141
+ expect(queryClient.getQueryState(key())).toMatchObject({
1142
+ data: initialData,
1143
+ status: 'success',
1144
+ error: null,
1145
+ })
1164
1146
  })
1165
1147
 
1166
1148
  it('should be able to override the cursor in the fetchNextPage callback', async () => {
@@ -1857,7 +1839,7 @@ describe('useInfiniteQuery', () => {
1857
1839
  const promise = new Promise<string>((resolve, reject) => {
1858
1840
  cancelFn = jest.fn(() => reject('Cancelled'))
1859
1841
  signal?.addEventListener('abort', cancelFn)
1860
- sleep(10).then(() => resolve('OK'))
1842
+ sleep(20).then(() => resolve('OK'))
1861
1843
  })
1862
1844
 
1863
1845
  return promise
@@ -1882,8 +1864,6 @@ describe('useInfiniteQuery', () => {
1882
1864
 
1883
1865
  await waitFor(() => screen.getByText('off'))
1884
1866
 
1885
- if (typeof AbortSignal === 'function') {
1886
- expect(cancelFn).toHaveBeenCalled()
1887
- }
1867
+ expect(cancelFn).toHaveBeenCalled()
1888
1868
  })
1889
1869
  })
@@ -273,6 +273,7 @@ describe('createQuery', () => {
273
273
  isFetching: true,
274
274
  isPaused: false,
275
275
  isLoading: true,
276
+ isInitialLoading: true,
276
277
  isLoadingError: false,
277
278
  isPlaceholderData: false,
278
279
  isPreviousData: false,
@@ -299,6 +300,7 @@ describe('createQuery', () => {
299
300
  isFetching: false,
300
301
  isPaused: false,
301
302
  isLoading: false,
303
+ isInitialLoading: false,
302
304
  isLoadingError: false,
303
305
  isPlaceholderData: false,
304
306
  isPreviousData: false,
@@ -361,6 +363,7 @@ describe('createQuery', () => {
361
363
  isFetching: true,
362
364
  isPaused: false,
363
365
  isLoading: true,
366
+ isInitialLoading: true,
364
367
  isLoadingError: false,
365
368
  isPlaceholderData: false,
366
369
  isPreviousData: false,
@@ -387,6 +390,7 @@ describe('createQuery', () => {
387
390
  isFetching: true,
388
391
  isPaused: false,
389
392
  isLoading: true,
393
+ isInitialLoading: true,
390
394
  isLoadingError: false,
391
395
  isPlaceholderData: false,
392
396
  isPreviousData: false,
@@ -413,6 +417,7 @@ describe('createQuery', () => {
413
417
  isFetching: false,
414
418
  isPaused: false,
415
419
  isLoading: false,
420
+ isInitialLoading: false,
416
421
  isLoadingError: true,
417
422
  isPlaceholderData: false,
418
423
  isPreviousData: false,
@@ -4936,7 +4941,7 @@ describe('createQuery', () => {
4936
4941
  const promise = new Promise<string>((resolve, reject) => {
4937
4942
  cancelFn = jest.fn(() => reject('Cancelled'))
4938
4943
  signal?.addEventListener('abort', cancelFn)
4939
- sleep(10).then(() => resolve('OK'))
4944
+ sleep(20).then(() => resolve('OK'))
4940
4945
  })
4941
4946
 
4942
4947
  return promise
@@ -4961,9 +4966,7 @@ describe('createQuery', () => {
4961
4966
 
4962
4967
  await waitFor(() => screen.getByText('off'))
4963
4968
 
4964
- if (typeof AbortSignal === 'function') {
4965
- expect(cancelFn).toHaveBeenCalled()
4966
- }
4969
+ expect(cancelFn).toHaveBeenCalled()
4967
4970
  })
4968
4971
 
4969
4972
  it('should cancel the query if the signal was consumed and there are no more subscriptions', async () => {
@@ -5013,19 +5016,11 @@ describe('createQuery', () => {
5013
5016
  dataUpdateCount: 1,
5014
5017
  })
5015
5018
 
5016
- if (typeof AbortSignal === 'function') {
5017
- expect(queryCache.find([key(), 1])?.state).toMatchObject({
5018
- data: undefined,
5019
- status: 'loading',
5020
- fetchStatus: 'idle',
5021
- })
5022
- } else {
5023
- expect(queryCache.find([key(), 1])?.state).toMatchObject({
5024
- data: 'data 1',
5025
- status: 'success',
5026
- dataUpdateCount: 1,
5027
- })
5028
- }
5019
+ expect(queryCache.find([key(), 1])?.state).toMatchObject({
5020
+ data: undefined,
5021
+ status: 'loading',
5022
+ fetchStatus: 'idle',
5023
+ })
5029
5024
 
5030
5025
  expect(queryCache.find([key(), 2])?.state).toMatchObject({
5031
5026
  data: 'data 2',
@@ -5033,19 +5028,11 @@ describe('createQuery', () => {
5033
5028
  dataUpdateCount: 1,
5034
5029
  })
5035
5030
 
5036
- if (typeof AbortSignal === 'function') {
5037
- expect(queryCache.find([key(), 3])?.state).toMatchObject({
5038
- data: undefined,
5039
- status: 'loading',
5040
- fetchStatus: 'idle',
5041
- })
5042
- } else {
5043
- expect(queryCache.find([key(), 3])?.state).toMatchObject({
5044
- data: 'data 3',
5045
- status: 'success',
5046
- dataUpdateCount: 1,
5047
- })
5048
- }
5031
+ expect(queryCache.find([key(), 3])?.state).toMatchObject({
5032
+ data: undefined,
5033
+ status: 'loading',
5034
+ fetchStatus: 'idle',
5035
+ })
5049
5036
  })
5050
5037
 
5051
5038
  it('should refetch when quickly switching to a failed query', async () => {
@@ -6195,7 +6182,7 @@ describe('createQuery', () => {
6195
6182
  status: 'success',
6196
6183
  })
6197
6184
 
6198
- expect(count).toBe(typeof AbortSignal === 'function' ? 1 : 2)
6185
+ expect(count).toBe(1)
6199
6186
 
6200
6187
  onlineMock.mockRestore()
6201
6188
  })