@tanstack/solid-query 5.59.16 → 5.59.20
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 +4 -3
- 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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/solid-query",
|
|
3
|
-
"version": "5.59.
|
|
3
|
+
"version": "5.59.20",
|
|
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",
|
|
@@ -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
|
-
})
|