@tanstack/solid-query 5.59.17 → 5.60.4
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/build/dev.cjs +2 -2
- package/build/dev.js +2 -2
- package/build/index.cjs +2 -2
- package/build/index.js +2 -2
- package/package.json +4 -3
- package/src/createQueries.ts +3 -2
- package/src/utils.ts +1 -1
- package/src/__tests__/QueryClientProvider.test.tsx +0 -180
- package/src/__tests__/createInfiniteQuery.test.tsx +0 -2093
- package/src/__tests__/createMutation.test.tsx +0 -1238
- package/src/__tests__/createQueries.test.tsx +0 -732
- package/src/__tests__/createQuery.test-d.tsx +0 -98
- package/src/__tests__/createQuery.test.tsx +0 -6055
- package/src/__tests__/infiniteQueryOptions.test-d.tsx +0 -81
- package/src/__tests__/queryOptions.test-d.tsx +0 -146
- package/src/__tests__/suspense.test.tsx +0 -956
- package/src/__tests__/transition.test.tsx +0 -60
- package/src/__tests__/useIsFetching.test.tsx +0 -251
- package/src/__tests__/useIsMutating.test.tsx +0 -248
- package/src/__tests__/useMutationState.test-d.tsx +0 -21
- package/src/__tests__/useMutationState.test.tsx +0 -68
- package/src/__tests__/utils.tsx +0 -61
package/build/dev.cjs
CHANGED
|
@@ -495,10 +495,10 @@ function createQueries(queriesOptions, queryClient) {
|
|
|
495
495
|
taskQueue = [];
|
|
496
496
|
});
|
|
497
497
|
});
|
|
498
|
-
let unsubscribe =
|
|
498
|
+
let unsubscribe = noop;
|
|
499
499
|
solidJs.createComputed((cleanup) => {
|
|
500
500
|
cleanup?.();
|
|
501
|
-
unsubscribe = isRestoring() ?
|
|
501
|
+
unsubscribe = isRestoring() ? noop : subscribeToObserver();
|
|
502
502
|
return () => queueMicrotask(unsubscribe);
|
|
503
503
|
});
|
|
504
504
|
solidJs.onCleanup(unsubscribe);
|
package/build/dev.js
CHANGED
|
@@ -494,10 +494,10 @@ function createQueries(queriesOptions, queryClient) {
|
|
|
494
494
|
taskQueue = [];
|
|
495
495
|
});
|
|
496
496
|
});
|
|
497
|
-
let unsubscribe =
|
|
497
|
+
let unsubscribe = noop;
|
|
498
498
|
createComputed((cleanup) => {
|
|
499
499
|
cleanup?.();
|
|
500
|
-
unsubscribe = isRestoring() ?
|
|
500
|
+
unsubscribe = isRestoring() ? noop : subscribeToObserver();
|
|
501
501
|
return () => queueMicrotask(unsubscribe);
|
|
502
502
|
});
|
|
503
503
|
onCleanup(unsubscribe);
|
package/build/index.cjs
CHANGED
|
@@ -486,10 +486,10 @@ function createQueries(queriesOptions, queryClient) {
|
|
|
486
486
|
taskQueue = [];
|
|
487
487
|
});
|
|
488
488
|
});
|
|
489
|
-
let unsubscribe =
|
|
489
|
+
let unsubscribe = noop;
|
|
490
490
|
solidJs.createComputed((cleanup) => {
|
|
491
491
|
cleanup?.();
|
|
492
|
-
unsubscribe = isRestoring() ?
|
|
492
|
+
unsubscribe = isRestoring() ? noop : subscribeToObserver();
|
|
493
493
|
return () => queueMicrotask(unsubscribe);
|
|
494
494
|
});
|
|
495
495
|
solidJs.onCleanup(unsubscribe);
|
package/build/index.js
CHANGED
|
@@ -485,10 +485,10 @@ function createQueries(queriesOptions, queryClient) {
|
|
|
485
485
|
taskQueue = [];
|
|
486
486
|
});
|
|
487
487
|
});
|
|
488
|
-
let unsubscribe =
|
|
488
|
+
let unsubscribe = noop;
|
|
489
489
|
createComputed((cleanup) => {
|
|
490
490
|
cleanup?.();
|
|
491
|
-
unsubscribe = isRestoring() ?
|
|
491
|
+
unsubscribe = isRestoring() ? noop : subscribeToObserver();
|
|
492
492
|
return () => queueMicrotask(unsubscribe);
|
|
493
493
|
});
|
|
494
494
|
onCleanup(unsubscribe);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/solid-query",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.60.4",
|
|
4
4
|
"description": "Primitives for managing, caching and syncing asynchronous and remote data in Solid",
|
|
5
5
|
"author": "tannerlinsley",
|
|
6
6
|
"license": "MIT",
|
|
@@ -41,10 +41,11 @@
|
|
|
41
41
|
},
|
|
42
42
|
"files": [
|
|
43
43
|
"build",
|
|
44
|
-
"src"
|
|
44
|
+
"src",
|
|
45
|
+
"!src/__tests__"
|
|
45
46
|
],
|
|
46
47
|
"dependencies": {
|
|
47
|
-
"@tanstack/query-core": "5.59.
|
|
48
|
+
"@tanstack/query-core": "5.59.20"
|
|
48
49
|
},
|
|
49
50
|
"devDependencies": {
|
|
50
51
|
"solid-js": "^1.8.19",
|
package/src/createQueries.ts
CHANGED
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
} from 'solid-js'
|
|
14
14
|
import { useQueryClient } from './QueryClientProvider'
|
|
15
15
|
import { useIsRestoring } from './isRestoring'
|
|
16
|
+
import { noop } from './utils'
|
|
16
17
|
import type { CreateQueryResult, SolidQueryOptions } from './types'
|
|
17
18
|
import type { Accessor } from 'solid-js'
|
|
18
19
|
import type { QueryClient } from './QueryClient'
|
|
@@ -305,10 +306,10 @@ export function createQueries<
|
|
|
305
306
|
})
|
|
306
307
|
})
|
|
307
308
|
|
|
308
|
-
let unsubscribe
|
|
309
|
+
let unsubscribe = noop
|
|
309
310
|
createComputed<() => void>((cleanup) => {
|
|
310
311
|
cleanup?.()
|
|
311
|
-
unsubscribe = isRestoring() ?
|
|
312
|
+
unsubscribe = isRestoring() ? noop : subscribeToObserver()
|
|
312
313
|
// cleanup needs to be scheduled after synchronous effects take place
|
|
313
314
|
return () => queueMicrotask(unsubscribe)
|
|
314
315
|
})
|
package/src/utils.ts
CHANGED
|
@@ -1,180 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it, vi } from 'vitest'
|
|
2
|
-
import { render, waitFor } from '@solidjs/testing-library'
|
|
3
|
-
import { QueryCache } from '@tanstack/query-core'
|
|
4
|
-
import { QueryClientProvider, createQuery, useQueryClient } from '..'
|
|
5
|
-
import { createQueryClient, queryKey, sleep } from './utils'
|
|
6
|
-
|
|
7
|
-
describe('QueryClientProvider', () => {
|
|
8
|
-
it('sets a specific cache for all queries to use', async () => {
|
|
9
|
-
const key = queryKey()
|
|
10
|
-
|
|
11
|
-
const queryCache = new QueryCache()
|
|
12
|
-
const queryClient = createQueryClient({ queryCache })
|
|
13
|
-
|
|
14
|
-
function Page() {
|
|
15
|
-
const query = createQuery(() => ({
|
|
16
|
-
queryKey: key,
|
|
17
|
-
queryFn: async () => {
|
|
18
|
-
await sleep(10)
|
|
19
|
-
return 'test'
|
|
20
|
-
},
|
|
21
|
-
}))
|
|
22
|
-
|
|
23
|
-
return (
|
|
24
|
-
<div>
|
|
25
|
-
<h1>{query.data}</h1>
|
|
26
|
-
</div>
|
|
27
|
-
)
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
const rendered = render(() => (
|
|
31
|
-
<QueryClientProvider client={queryClient}>
|
|
32
|
-
<Page />
|
|
33
|
-
</QueryClientProvider>
|
|
34
|
-
))
|
|
35
|
-
|
|
36
|
-
await waitFor(() => {
|
|
37
|
-
return rendered.getByText('test')
|
|
38
|
-
})
|
|
39
|
-
|
|
40
|
-
expect(queryCache.find({ queryKey: key })).toBeDefined()
|
|
41
|
-
})
|
|
42
|
-
|
|
43
|
-
it('allows multiple caches to be partitioned', async () => {
|
|
44
|
-
const key1 = queryKey()
|
|
45
|
-
const key2 = queryKey()
|
|
46
|
-
|
|
47
|
-
const queryCache1 = new QueryCache()
|
|
48
|
-
const queryCache2 = new QueryCache()
|
|
49
|
-
|
|
50
|
-
const queryClient1 = createQueryClient({ queryCache: queryCache1 })
|
|
51
|
-
const queryClient2 = createQueryClient({ queryCache: queryCache2 })
|
|
52
|
-
|
|
53
|
-
function Page1() {
|
|
54
|
-
const query = createQuery(() => ({
|
|
55
|
-
queryKey: key1,
|
|
56
|
-
queryFn: async () => {
|
|
57
|
-
await sleep(10)
|
|
58
|
-
return 'test1'
|
|
59
|
-
},
|
|
60
|
-
}))
|
|
61
|
-
|
|
62
|
-
return (
|
|
63
|
-
<div>
|
|
64
|
-
<h1>{query.data}</h1>
|
|
65
|
-
</div>
|
|
66
|
-
)
|
|
67
|
-
}
|
|
68
|
-
function Page2() {
|
|
69
|
-
const query = createQuery(() => ({
|
|
70
|
-
queryKey: key2,
|
|
71
|
-
queryFn: async () => {
|
|
72
|
-
await sleep(10)
|
|
73
|
-
return 'test2'
|
|
74
|
-
},
|
|
75
|
-
}))
|
|
76
|
-
|
|
77
|
-
return (
|
|
78
|
-
<div>
|
|
79
|
-
<h1>{query.data}</h1>
|
|
80
|
-
</div>
|
|
81
|
-
)
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
const rendered = render(() => (
|
|
85
|
-
<>
|
|
86
|
-
<QueryClientProvider client={queryClient1}>
|
|
87
|
-
<Page1 />
|
|
88
|
-
</QueryClientProvider>
|
|
89
|
-
<QueryClientProvider client={queryClient2}>
|
|
90
|
-
<Page2 />
|
|
91
|
-
</QueryClientProvider>
|
|
92
|
-
</>
|
|
93
|
-
))
|
|
94
|
-
|
|
95
|
-
await waitFor(() => rendered.getByText('test1'))
|
|
96
|
-
await waitFor(() => rendered.getByText('test2'))
|
|
97
|
-
|
|
98
|
-
expect(queryCache1.find({ queryKey: key1 })).toBeDefined()
|
|
99
|
-
expect(queryCache1.find({ queryKey: key2 })).not.toBeDefined()
|
|
100
|
-
expect(queryCache2.find({ queryKey: key1 })).not.toBeDefined()
|
|
101
|
-
expect(queryCache2.find({ queryKey: key2 })).toBeDefined()
|
|
102
|
-
})
|
|
103
|
-
|
|
104
|
-
it("uses defaultOptions for queries when they don't provide their own config", async () => {
|
|
105
|
-
const key = queryKey()
|
|
106
|
-
|
|
107
|
-
const queryCache = new QueryCache()
|
|
108
|
-
const queryClient = createQueryClient({
|
|
109
|
-
queryCache,
|
|
110
|
-
defaultOptions: {
|
|
111
|
-
queries: {
|
|
112
|
-
gcTime: Infinity,
|
|
113
|
-
},
|
|
114
|
-
},
|
|
115
|
-
})
|
|
116
|
-
|
|
117
|
-
function Page() {
|
|
118
|
-
const query = createQuery(() => ({
|
|
119
|
-
queryKey: key,
|
|
120
|
-
queryFn: async () => {
|
|
121
|
-
await sleep(10)
|
|
122
|
-
return 'test'
|
|
123
|
-
},
|
|
124
|
-
}))
|
|
125
|
-
|
|
126
|
-
return (
|
|
127
|
-
<div>
|
|
128
|
-
<h1>{query.data}</h1>
|
|
129
|
-
</div>
|
|
130
|
-
)
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
const rendered = render(() => (
|
|
134
|
-
<QueryClientProvider client={queryClient}>
|
|
135
|
-
<Page />
|
|
136
|
-
</QueryClientProvider>
|
|
137
|
-
))
|
|
138
|
-
|
|
139
|
-
await waitFor(() => rendered.getByText('test'))
|
|
140
|
-
|
|
141
|
-
expect(queryCache.find({ queryKey: key })).toBeDefined()
|
|
142
|
-
expect(queryCache.find({ queryKey: key })?.options.gcTime).toBe(Infinity)
|
|
143
|
-
})
|
|
144
|
-
|
|
145
|
-
describe('useQueryClient', () => {
|
|
146
|
-
it('should throw an error if no query client has been set', () => {
|
|
147
|
-
const consoleMock = vi
|
|
148
|
-
.spyOn(console, 'error')
|
|
149
|
-
.mockImplementation(() => undefined)
|
|
150
|
-
|
|
151
|
-
function Page() {
|
|
152
|
-
useQueryClient()
|
|
153
|
-
return null
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
expect(() => render(() => <Page />)).toThrow(
|
|
157
|
-
'No QueryClient set, use QueryClientProvider to set one',
|
|
158
|
-
)
|
|
159
|
-
|
|
160
|
-
consoleMock.mockRestore()
|
|
161
|
-
})
|
|
162
|
-
})
|
|
163
|
-
|
|
164
|
-
it('should not throw an error if user provides custom query client', () => {
|
|
165
|
-
const consoleMock = vi
|
|
166
|
-
.spyOn(console, 'error')
|
|
167
|
-
.mockImplementation(() => undefined)
|
|
168
|
-
|
|
169
|
-
function Page() {
|
|
170
|
-
const client = createQueryClient()
|
|
171
|
-
useQueryClient(client)
|
|
172
|
-
return null
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
render(() => <Page />)
|
|
176
|
-
expect(consoleMock).not.toHaveBeenCalled()
|
|
177
|
-
|
|
178
|
-
consoleMock.mockRestore()
|
|
179
|
-
})
|
|
180
|
-
})
|