@tanstack/solid-query 4.7.1 → 4.7.2

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2021 Tanner Linsley
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanstack/solid-query",
3
- "version": "4.7.1",
3
+ "version": "4.7.2",
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.7.2"
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": "yarn test:jest --watch"
51
+ }
52
+ }
@@ -938,34 +938,28 @@ describe('useInfiniteQuery', () => {
938
938
  const firstCtx = fetchPage.mock.calls[callIndex]![0]
939
939
  expect(firstCtx.pageParam).toBeUndefined()
940
940
  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
- }
941
+ expect(firstCtx.signal).toBeInstanceOf(AbortSignal)
942
+ expect(firstCtx.signal?.aborted).toBe(false)
943
+ expect(onAborts[callIndex]).not.toHaveBeenCalled()
944
+ expect(abortListeners[callIndex]).not.toHaveBeenCalled()
947
945
 
948
946
  callIndex = 1
949
947
  const secondCtx = fetchPage.mock.calls[callIndex]![0]
950
948
  expect(secondCtx.pageParam).toBe(11)
951
949
  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
- }
950
+ expect(secondCtx.signal).toBeInstanceOf(AbortSignal)
951
+ expect(secondCtx.signal?.aborted).toBe(true)
952
+ expect(onAborts[callIndex]).toHaveBeenCalledTimes(1)
953
+ expect(abortListeners[callIndex]).toHaveBeenCalledTimes(1)
958
954
 
959
955
  callIndex = 2
960
956
  const thirdCtx = fetchPage.mock.calls[callIndex]![0]
961
957
  expect(thirdCtx.pageParam).toBe(11)
962
958
  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
- }
959
+ expect(thirdCtx.signal).toBeInstanceOf(AbortSignal)
960
+ expect(thirdCtx.signal?.aborted).toBe(false)
961
+ expect(onAborts[callIndex]).not.toHaveBeenCalled()
962
+ expect(abortListeners[callIndex]).not.toHaveBeenCalled()
969
963
  })
970
964
 
971
965
  it('should not cancel an ongoing fetchNextPage request when another fetchNextPage is invoked if `cancelRefetch: false` is used ', async () => {
@@ -1024,23 +1018,19 @@ describe('useInfiniteQuery', () => {
1024
1018
  const firstCtx = fetchPage.mock.calls[callIndex]![0]
1025
1019
  expect(firstCtx.pageParam).toBeUndefined()
1026
1020
  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
- }
1021
+ expect(firstCtx.signal).toBeInstanceOf(AbortSignal)
1022
+ expect(firstCtx.signal?.aborted).toBe(false)
1023
+ expect(onAborts[callIndex]).not.toHaveBeenCalled()
1024
+ expect(abortListeners[callIndex]).not.toHaveBeenCalled()
1033
1025
 
1034
1026
  callIndex = 1
1035
1027
  const secondCtx = fetchPage.mock.calls[callIndex]![0]
1036
1028
  expect(secondCtx.pageParam).toBe(11)
1037
1029
  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
- }
1030
+ expect(secondCtx.signal).toBeInstanceOf(AbortSignal)
1031
+ expect(secondCtx.signal?.aborted).toBe(false)
1032
+ expect(onAborts[callIndex]).not.toHaveBeenCalled()
1033
+ expect(abortListeners[callIndex]).not.toHaveBeenCalled()
1044
1034
  })
1045
1035
 
1046
1036
  it('should keep fetching first page when not loaded yet and triggering fetch more', async () => {
@@ -1145,22 +1135,12 @@ describe('useInfiniteQuery', () => {
1145
1135
 
1146
1136
  await sleep(300)
1147
1137
 
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
- }
1138
+ expect(fetches).toBe(2)
1139
+ expect(queryClient.getQueryState(key())).toMatchObject({
1140
+ data: initialData,
1141
+ status: 'success',
1142
+ error: null,
1143
+ })
1164
1144
  })
1165
1145
 
1166
1146
  it('should be able to override the cursor in the fetchNextPage callback', async () => {
@@ -1857,7 +1837,7 @@ describe('useInfiniteQuery', () => {
1857
1837
  const promise = new Promise<string>((resolve, reject) => {
1858
1838
  cancelFn = jest.fn(() => reject('Cancelled'))
1859
1839
  signal?.addEventListener('abort', cancelFn)
1860
- sleep(10).then(() => resolve('OK'))
1840
+ sleep(20).then(() => resolve('OK'))
1861
1841
  })
1862
1842
 
1863
1843
  return promise
@@ -1882,8 +1862,6 @@ describe('useInfiniteQuery', () => {
1882
1862
 
1883
1863
  await waitFor(() => screen.getByText('off'))
1884
1864
 
1885
- if (typeof AbortSignal === 'function') {
1886
- expect(cancelFn).toHaveBeenCalled()
1887
- }
1865
+ expect(cancelFn).toHaveBeenCalled()
1888
1866
  })
1889
1867
  })
@@ -4936,7 +4936,7 @@ describe('createQuery', () => {
4936
4936
  const promise = new Promise<string>((resolve, reject) => {
4937
4937
  cancelFn = jest.fn(() => reject('Cancelled'))
4938
4938
  signal?.addEventListener('abort', cancelFn)
4939
- sleep(10).then(() => resolve('OK'))
4939
+ sleep(20).then(() => resolve('OK'))
4940
4940
  })
4941
4941
 
4942
4942
  return promise
@@ -4961,9 +4961,7 @@ describe('createQuery', () => {
4961
4961
 
4962
4962
  await waitFor(() => screen.getByText('off'))
4963
4963
 
4964
- if (typeof AbortSignal === 'function') {
4965
- expect(cancelFn).toHaveBeenCalled()
4966
- }
4964
+ expect(cancelFn).toHaveBeenCalled()
4967
4965
  })
4968
4966
 
4969
4967
  it('should cancel the query if the signal was consumed and there are no more subscriptions', async () => {
@@ -5013,19 +5011,11 @@ describe('createQuery', () => {
5013
5011
  dataUpdateCount: 1,
5014
5012
  })
5015
5013
 
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
- }
5014
+ expect(queryCache.find([key(), 1])?.state).toMatchObject({
5015
+ data: undefined,
5016
+ status: 'loading',
5017
+ fetchStatus: 'idle',
5018
+ })
5029
5019
 
5030
5020
  expect(queryCache.find([key(), 2])?.state).toMatchObject({
5031
5021
  data: 'data 2',
@@ -5033,19 +5023,11 @@ describe('createQuery', () => {
5033
5023
  dataUpdateCount: 1,
5034
5024
  })
5035
5025
 
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
- }
5026
+ expect(queryCache.find([key(), 3])?.state).toMatchObject({
5027
+ data: undefined,
5028
+ status: 'loading',
5029
+ fetchStatus: 'idle',
5030
+ })
5049
5031
  })
5050
5032
 
5051
5033
  it('should refetch when quickly switching to a failed query', async () => {
@@ -6195,7 +6177,7 @@ describe('createQuery', () => {
6195
6177
  status: 'success',
6196
6178
  })
6197
6179
 
6198
- expect(count).toBe(typeof AbortSignal === 'function' ? 1 : 2)
6180
+ expect(count).toBe(1)
6199
6181
 
6200
6182
  onlineMock.mockRestore()
6201
6183
  })