@tanstack/solid-query 5.30.3 → 5.30.5
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 +24 -29
- package/build/dev.js +24 -29
- package/build/index.cjs +24 -29
- package/build/index.js +24 -29
- package/package.json +1 -1
- package/src/createBaseQuery.ts +33 -53
package/build/dev.cjs
CHANGED
|
@@ -78,27 +78,23 @@ function reconcileFn(store$1, result, reconcileOption, queryHash) {
|
|
|
78
78
|
return { ...result, data: newData };
|
|
79
79
|
}
|
|
80
80
|
var hydratableObserverResult = (query, result) => {
|
|
81
|
-
|
|
82
|
-
return result;
|
|
83
|
-
return {
|
|
81
|
+
const obj = {
|
|
84
82
|
...store.unwrap(result),
|
|
85
|
-
//
|
|
86
|
-
//
|
|
87
|
-
refetch: void 0
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
fetchPreviousPage
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
// Unsetting these properties on the server since they might not be serializable
|
|
99
|
-
fetchFailureReason: null,
|
|
100
|
-
fetchMeta: null
|
|
83
|
+
// During SSR, functions cannot be serialized, so we need to remove them
|
|
84
|
+
// This is safe because we will add these functions back when the query is hydrated
|
|
85
|
+
refetch: void 0
|
|
86
|
+
};
|
|
87
|
+
if ("fetchNextPage" in result) {
|
|
88
|
+
obj.fetchNextPage = void 0;
|
|
89
|
+
obj.fetchPreviousPage = void 0;
|
|
90
|
+
}
|
|
91
|
+
obj.hydrationData = {
|
|
92
|
+
state: query.state,
|
|
93
|
+
queryKey: query.queryKey,
|
|
94
|
+
queryHash: query.queryHash,
|
|
95
|
+
...query.meta && { meta: query.meta }
|
|
101
96
|
};
|
|
97
|
+
return obj;
|
|
102
98
|
};
|
|
103
99
|
function createBaseQuery(options, Observer, queryClient) {
|
|
104
100
|
const client = solidJs.createMemo(() => exports.useQueryClient(queryClient?.()));
|
|
@@ -168,6 +164,10 @@ function createBaseQuery(options, Observer, queryClient) {
|
|
|
168
164
|
if (typeof v === "function") {
|
|
169
165
|
v = v(unwrapped);
|
|
170
166
|
}
|
|
167
|
+
if (v.hydrationData) {
|
|
168
|
+
const { hydrationData, ...rest } = v;
|
|
169
|
+
v = rest;
|
|
170
|
+
}
|
|
171
171
|
setStateWithReconciliation(v);
|
|
172
172
|
}
|
|
173
173
|
];
|
|
@@ -193,9 +193,8 @@ function createBaseQuery(options, Observer, queryClient) {
|
|
|
193
193
|
return reject(observerResult.error);
|
|
194
194
|
}
|
|
195
195
|
if (!observerResult.isLoading) {
|
|
196
|
-
const query = obs.getCurrentQuery();
|
|
197
196
|
resolver = null;
|
|
198
|
-
return resolve(
|
|
197
|
+
return resolve(observerResult);
|
|
199
198
|
}
|
|
200
199
|
setStateWithReconciliation(observerResult);
|
|
201
200
|
});
|
|
@@ -214,15 +213,10 @@ function createBaseQuery(options, Observer, queryClient) {
|
|
|
214
213
|
* Note that this is only invoked on the client, for queries that were originally run on the server.
|
|
215
214
|
*/
|
|
216
215
|
onHydrated(_k, info) {
|
|
217
|
-
if (info.value) {
|
|
216
|
+
if (info.value && "hydrationData" in info.value) {
|
|
218
217
|
queryCore.hydrate(client(), {
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
queryKey: initialOptions.queryKey,
|
|
222
|
-
queryHash: initialOptions.queryHash,
|
|
223
|
-
state: info.value
|
|
224
|
-
}
|
|
225
|
-
]
|
|
218
|
+
// @ts-expect-error - hydrationData is not correctly typed internally
|
|
219
|
+
queries: [{ ...info.value.hydrationData }]
|
|
226
220
|
});
|
|
227
221
|
}
|
|
228
222
|
if (unsubscribe)
|
|
@@ -284,6 +278,7 @@ function createBaseQuery(options, Observer, queryClient) {
|
|
|
284
278
|
([obs, opts]) => {
|
|
285
279
|
obs.setOptions(opts);
|
|
286
280
|
setStateWithReconciliation(obs.getOptimisticResult(opts));
|
|
281
|
+
refetch();
|
|
287
282
|
},
|
|
288
283
|
{ defer: true }
|
|
289
284
|
)
|
package/build/dev.js
CHANGED
|
@@ -77,27 +77,23 @@ function reconcileFn(store, result, reconcileOption, queryHash) {
|
|
|
77
77
|
return { ...result, data: newData };
|
|
78
78
|
}
|
|
79
79
|
var hydratableObserverResult = (query, result) => {
|
|
80
|
-
|
|
81
|
-
return result;
|
|
82
|
-
return {
|
|
80
|
+
const obj = {
|
|
83
81
|
...unwrap(result),
|
|
84
|
-
//
|
|
85
|
-
//
|
|
86
|
-
refetch: void 0
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
fetchPreviousPage
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
// Unsetting these properties on the server since they might not be serializable
|
|
98
|
-
fetchFailureReason: null,
|
|
99
|
-
fetchMeta: null
|
|
82
|
+
// During SSR, functions cannot be serialized, so we need to remove them
|
|
83
|
+
// This is safe because we will add these functions back when the query is hydrated
|
|
84
|
+
refetch: void 0
|
|
85
|
+
};
|
|
86
|
+
if ("fetchNextPage" in result) {
|
|
87
|
+
obj.fetchNextPage = void 0;
|
|
88
|
+
obj.fetchPreviousPage = void 0;
|
|
89
|
+
}
|
|
90
|
+
obj.hydrationData = {
|
|
91
|
+
state: query.state,
|
|
92
|
+
queryKey: query.queryKey,
|
|
93
|
+
queryHash: query.queryHash,
|
|
94
|
+
...query.meta && { meta: query.meta }
|
|
100
95
|
};
|
|
96
|
+
return obj;
|
|
101
97
|
};
|
|
102
98
|
function createBaseQuery(options, Observer, queryClient) {
|
|
103
99
|
const client = createMemo(() => useQueryClient(queryClient?.()));
|
|
@@ -167,6 +163,10 @@ function createBaseQuery(options, Observer, queryClient) {
|
|
|
167
163
|
if (typeof v === "function") {
|
|
168
164
|
v = v(unwrapped);
|
|
169
165
|
}
|
|
166
|
+
if (v.hydrationData) {
|
|
167
|
+
const { hydrationData, ...rest } = v;
|
|
168
|
+
v = rest;
|
|
169
|
+
}
|
|
170
170
|
setStateWithReconciliation(v);
|
|
171
171
|
}
|
|
172
172
|
];
|
|
@@ -192,9 +192,8 @@ function createBaseQuery(options, Observer, queryClient) {
|
|
|
192
192
|
return reject(observerResult.error);
|
|
193
193
|
}
|
|
194
194
|
if (!observerResult.isLoading) {
|
|
195
|
-
const query = obs.getCurrentQuery();
|
|
196
195
|
resolver = null;
|
|
197
|
-
return resolve(
|
|
196
|
+
return resolve(observerResult);
|
|
198
197
|
}
|
|
199
198
|
setStateWithReconciliation(observerResult);
|
|
200
199
|
});
|
|
@@ -213,15 +212,10 @@ function createBaseQuery(options, Observer, queryClient) {
|
|
|
213
212
|
* Note that this is only invoked on the client, for queries that were originally run on the server.
|
|
214
213
|
*/
|
|
215
214
|
onHydrated(_k, info) {
|
|
216
|
-
if (info.value) {
|
|
215
|
+
if (info.value && "hydrationData" in info.value) {
|
|
217
216
|
hydrate(client(), {
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
queryKey: initialOptions.queryKey,
|
|
221
|
-
queryHash: initialOptions.queryHash,
|
|
222
|
-
state: info.value
|
|
223
|
-
}
|
|
224
|
-
]
|
|
217
|
+
// @ts-expect-error - hydrationData is not correctly typed internally
|
|
218
|
+
queries: [{ ...info.value.hydrationData }]
|
|
225
219
|
});
|
|
226
220
|
}
|
|
227
221
|
if (unsubscribe)
|
|
@@ -283,6 +277,7 @@ function createBaseQuery(options, Observer, queryClient) {
|
|
|
283
277
|
([obs, opts]) => {
|
|
284
278
|
obs.setOptions(opts);
|
|
285
279
|
setStateWithReconciliation(obs.getOptimisticResult(opts));
|
|
280
|
+
refetch();
|
|
286
281
|
},
|
|
287
282
|
{ defer: true }
|
|
288
283
|
)
|
package/build/index.cjs
CHANGED
|
@@ -69,27 +69,23 @@ function reconcileFn(store$1, result, reconcileOption, queryHash) {
|
|
|
69
69
|
return { ...result, data: newData };
|
|
70
70
|
}
|
|
71
71
|
var hydratableObserverResult = (query, result) => {
|
|
72
|
-
|
|
73
|
-
return result;
|
|
74
|
-
return {
|
|
72
|
+
const obj = {
|
|
75
73
|
...store.unwrap(result),
|
|
76
|
-
//
|
|
77
|
-
//
|
|
78
|
-
refetch: void 0
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
fetchPreviousPage
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
// Unsetting these properties on the server since they might not be serializable
|
|
90
|
-
fetchFailureReason: null,
|
|
91
|
-
fetchMeta: null
|
|
74
|
+
// During SSR, functions cannot be serialized, so we need to remove them
|
|
75
|
+
// This is safe because we will add these functions back when the query is hydrated
|
|
76
|
+
refetch: void 0
|
|
77
|
+
};
|
|
78
|
+
if ("fetchNextPage" in result) {
|
|
79
|
+
obj.fetchNextPage = void 0;
|
|
80
|
+
obj.fetchPreviousPage = void 0;
|
|
81
|
+
}
|
|
82
|
+
obj.hydrationData = {
|
|
83
|
+
state: query.state,
|
|
84
|
+
queryKey: query.queryKey,
|
|
85
|
+
queryHash: query.queryHash,
|
|
86
|
+
...query.meta && { meta: query.meta }
|
|
92
87
|
};
|
|
88
|
+
return obj;
|
|
93
89
|
};
|
|
94
90
|
function createBaseQuery(options, Observer, queryClient) {
|
|
95
91
|
const client = solidJs.createMemo(() => exports.useQueryClient(queryClient?.()));
|
|
@@ -159,6 +155,10 @@ function createBaseQuery(options, Observer, queryClient) {
|
|
|
159
155
|
if (typeof v === "function") {
|
|
160
156
|
v = v(unwrapped);
|
|
161
157
|
}
|
|
158
|
+
if (v.hydrationData) {
|
|
159
|
+
const { hydrationData, ...rest } = v;
|
|
160
|
+
v = rest;
|
|
161
|
+
}
|
|
162
162
|
setStateWithReconciliation(v);
|
|
163
163
|
}
|
|
164
164
|
];
|
|
@@ -184,9 +184,8 @@ function createBaseQuery(options, Observer, queryClient) {
|
|
|
184
184
|
return reject(observerResult.error);
|
|
185
185
|
}
|
|
186
186
|
if (!observerResult.isLoading) {
|
|
187
|
-
const query = obs.getCurrentQuery();
|
|
188
187
|
resolver = null;
|
|
189
|
-
return resolve(
|
|
188
|
+
return resolve(observerResult);
|
|
190
189
|
}
|
|
191
190
|
setStateWithReconciliation(observerResult);
|
|
192
191
|
});
|
|
@@ -205,15 +204,10 @@ function createBaseQuery(options, Observer, queryClient) {
|
|
|
205
204
|
* Note that this is only invoked on the client, for queries that were originally run on the server.
|
|
206
205
|
*/
|
|
207
206
|
onHydrated(_k, info) {
|
|
208
|
-
if (info.value) {
|
|
207
|
+
if (info.value && "hydrationData" in info.value) {
|
|
209
208
|
queryCore.hydrate(client(), {
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
queryKey: initialOptions.queryKey,
|
|
213
|
-
queryHash: initialOptions.queryHash,
|
|
214
|
-
state: info.value
|
|
215
|
-
}
|
|
216
|
-
]
|
|
209
|
+
// @ts-expect-error - hydrationData is not correctly typed internally
|
|
210
|
+
queries: [{ ...info.value.hydrationData }]
|
|
217
211
|
});
|
|
218
212
|
}
|
|
219
213
|
if (unsubscribe)
|
|
@@ -275,6 +269,7 @@ function createBaseQuery(options, Observer, queryClient) {
|
|
|
275
269
|
([obs, opts]) => {
|
|
276
270
|
obs.setOptions(opts);
|
|
277
271
|
setStateWithReconciliation(obs.getOptimisticResult(opts));
|
|
272
|
+
refetch();
|
|
278
273
|
},
|
|
279
274
|
{ defer: true }
|
|
280
275
|
)
|
package/build/index.js
CHANGED
|
@@ -68,27 +68,23 @@ function reconcileFn(store, result, reconcileOption, queryHash) {
|
|
|
68
68
|
return { ...result, data: newData };
|
|
69
69
|
}
|
|
70
70
|
var hydratableObserverResult = (query, result) => {
|
|
71
|
-
|
|
72
|
-
return result;
|
|
73
|
-
return {
|
|
71
|
+
const obj = {
|
|
74
72
|
...unwrap(result),
|
|
75
|
-
//
|
|
76
|
-
//
|
|
77
|
-
refetch: void 0
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
fetchPreviousPage
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
// Unsetting these properties on the server since they might not be serializable
|
|
89
|
-
fetchFailureReason: null,
|
|
90
|
-
fetchMeta: null
|
|
73
|
+
// During SSR, functions cannot be serialized, so we need to remove them
|
|
74
|
+
// This is safe because we will add these functions back when the query is hydrated
|
|
75
|
+
refetch: void 0
|
|
76
|
+
};
|
|
77
|
+
if ("fetchNextPage" in result) {
|
|
78
|
+
obj.fetchNextPage = void 0;
|
|
79
|
+
obj.fetchPreviousPage = void 0;
|
|
80
|
+
}
|
|
81
|
+
obj.hydrationData = {
|
|
82
|
+
state: query.state,
|
|
83
|
+
queryKey: query.queryKey,
|
|
84
|
+
queryHash: query.queryHash,
|
|
85
|
+
...query.meta && { meta: query.meta }
|
|
91
86
|
};
|
|
87
|
+
return obj;
|
|
92
88
|
};
|
|
93
89
|
function createBaseQuery(options, Observer, queryClient) {
|
|
94
90
|
const client = createMemo(() => useQueryClient(queryClient?.()));
|
|
@@ -158,6 +154,10 @@ function createBaseQuery(options, Observer, queryClient) {
|
|
|
158
154
|
if (typeof v === "function") {
|
|
159
155
|
v = v(unwrapped);
|
|
160
156
|
}
|
|
157
|
+
if (v.hydrationData) {
|
|
158
|
+
const { hydrationData, ...rest } = v;
|
|
159
|
+
v = rest;
|
|
160
|
+
}
|
|
161
161
|
setStateWithReconciliation(v);
|
|
162
162
|
}
|
|
163
163
|
];
|
|
@@ -183,9 +183,8 @@ function createBaseQuery(options, Observer, queryClient) {
|
|
|
183
183
|
return reject(observerResult.error);
|
|
184
184
|
}
|
|
185
185
|
if (!observerResult.isLoading) {
|
|
186
|
-
const query = obs.getCurrentQuery();
|
|
187
186
|
resolver = null;
|
|
188
|
-
return resolve(
|
|
187
|
+
return resolve(observerResult);
|
|
189
188
|
}
|
|
190
189
|
setStateWithReconciliation(observerResult);
|
|
191
190
|
});
|
|
@@ -204,15 +203,10 @@ function createBaseQuery(options, Observer, queryClient) {
|
|
|
204
203
|
* Note that this is only invoked on the client, for queries that were originally run on the server.
|
|
205
204
|
*/
|
|
206
205
|
onHydrated(_k, info) {
|
|
207
|
-
if (info.value) {
|
|
206
|
+
if (info.value && "hydrationData" in info.value) {
|
|
208
207
|
hydrate(client(), {
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
queryKey: initialOptions.queryKey,
|
|
212
|
-
queryHash: initialOptions.queryHash,
|
|
213
|
-
state: info.value
|
|
214
|
-
}
|
|
215
|
-
]
|
|
208
|
+
// @ts-expect-error - hydrationData is not correctly typed internally
|
|
209
|
+
queries: [{ ...info.value.hydrationData }]
|
|
216
210
|
});
|
|
217
211
|
}
|
|
218
212
|
if (unsubscribe)
|
|
@@ -274,6 +268,7 @@ function createBaseQuery(options, Observer, queryClient) {
|
|
|
274
268
|
([obs, opts]) => {
|
|
275
269
|
obs.setOptions(opts);
|
|
276
270
|
setStateWithReconciliation(obs.getOptimisticResult(opts));
|
|
271
|
+
refetch();
|
|
277
272
|
},
|
|
278
273
|
{ defer: true }
|
|
279
274
|
)
|
package/package.json
CHANGED
package/src/createBaseQuery.ts
CHANGED
|
@@ -19,12 +19,10 @@ import type { CreateBaseQueryOptions } from './types'
|
|
|
19
19
|
import type { Accessor, Signal } from 'solid-js'
|
|
20
20
|
import type { QueryClient } from './QueryClient'
|
|
21
21
|
import type {
|
|
22
|
-
InfiniteQueryObserverResult,
|
|
23
22
|
Query,
|
|
24
23
|
QueryKey,
|
|
25
24
|
QueryObserver,
|
|
26
25
|
QueryObserverResult,
|
|
27
|
-
QueryState,
|
|
28
26
|
} from '@tanstack/query-core'
|
|
29
27
|
|
|
30
28
|
function reconcileFn<TData, TError>(
|
|
@@ -62,10 +60,6 @@ function reconcileFn<TData, TError>(
|
|
|
62
60
|
return { ...result, data: newData } as typeof result
|
|
63
61
|
}
|
|
64
62
|
|
|
65
|
-
type HydratableQueryState<TData, TError> = QueryObserverResult<TData, TError> &
|
|
66
|
-
QueryState<TData, TError> &
|
|
67
|
-
InfiniteQueryObserverResult<TData, TError>
|
|
68
|
-
|
|
69
63
|
/**
|
|
70
64
|
* Solid's `onHydrated` functionality will silently "fail" (hydrate with an empty object)
|
|
71
65
|
* if the resource data is not serializable.
|
|
@@ -80,42 +74,29 @@ const hydratableObserverResult = <
|
|
|
80
74
|
query: Query<TQueryFnData, TError, TData, TQueryKey>,
|
|
81
75
|
result: QueryObserverResult<TDataHydratable, TError>,
|
|
82
76
|
) => {
|
|
83
|
-
|
|
84
|
-
if (!isServer) return result as HydratableQueryState<TDataHydratable, TError>
|
|
85
|
-
|
|
86
|
-
return {
|
|
77
|
+
const obj: any = {
|
|
87
78
|
...unwrap(result),
|
|
79
|
+
// During SSR, functions cannot be serialized, so we need to remove them
|
|
80
|
+
// This is safe because we will add these functions back when the query is hydrated
|
|
81
|
+
refetch: undefined,
|
|
82
|
+
}
|
|
88
83
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
>['refetch'],
|
|
95
|
-
|
|
96
|
-
// cast to fetchNextPage function should be safe, since we only remove it on the server,
|
|
97
|
-
fetchNextPage: undefined as unknown as HydratableQueryState<
|
|
98
|
-
TDataHydratable,
|
|
99
|
-
TError
|
|
100
|
-
>['fetchNextPage'],
|
|
101
|
-
|
|
102
|
-
// cast to fetchPreviousPage function should be safe, since we only remove it on the server,
|
|
103
|
-
fetchPreviousPage: undefined as unknown as HydratableQueryState<
|
|
104
|
-
TDataHydratable,
|
|
105
|
-
TError
|
|
106
|
-
>['fetchPreviousPage'],
|
|
84
|
+
// If the query is an infinite query, we need to remove additional properties
|
|
85
|
+
if ('fetchNextPage' in result) {
|
|
86
|
+
obj.fetchNextPage = undefined
|
|
87
|
+
obj.fetchPreviousPage = undefined
|
|
88
|
+
}
|
|
107
89
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
90
|
+
// We will also attach the dehydrated state of the query to the result
|
|
91
|
+
// This will be removed on client after hydration
|
|
92
|
+
obj.hydrationData = {
|
|
93
|
+
state: query.state,
|
|
94
|
+
queryKey: query.queryKey,
|
|
95
|
+
queryHash: query.queryHash,
|
|
96
|
+
...(query.meta && { meta: query.meta }),
|
|
97
|
+
}
|
|
114
98
|
|
|
115
|
-
|
|
116
|
-
fetchFailureReason: null,
|
|
117
|
-
fetchMeta: null,
|
|
118
|
-
} as HydratableQueryState<TDataHydratable, TError>
|
|
99
|
+
return obj
|
|
119
100
|
}
|
|
120
101
|
|
|
121
102
|
// Base Query Function that is used to create the query.
|
|
@@ -132,9 +113,7 @@ export function createBaseQuery<
|
|
|
132
113
|
Observer: typeof QueryObserver,
|
|
133
114
|
queryClient?: Accessor<QueryClient>,
|
|
134
115
|
) {
|
|
135
|
-
type ResourceData =
|
|
136
|
-
| HydratableQueryState<TData, TError>
|
|
137
|
-
| QueryObserverResult<TData, TError>
|
|
116
|
+
type ResourceData = QueryObserverResult<TData, TError>
|
|
138
117
|
|
|
139
118
|
const client = createMemo(() => useQueryClient(queryClient?.()))
|
|
140
119
|
const isRestoring = useIsRestoring()
|
|
@@ -221,12 +200,18 @@ export function createBaseQuery<
|
|
|
221
200
|
function createDeepSignal<T>(): Signal<T> {
|
|
222
201
|
return [
|
|
223
202
|
() => state,
|
|
224
|
-
(v:
|
|
203
|
+
(v: any) => {
|
|
225
204
|
const unwrapped = unwrap(state)
|
|
226
205
|
if (typeof v === 'function') {
|
|
227
206
|
v = v(unwrapped)
|
|
228
207
|
}
|
|
229
|
-
|
|
208
|
+
// Hydration data exists on first load after SSR,
|
|
209
|
+
// and should be removed from the observer result
|
|
210
|
+
if (v.hydrationData) {
|
|
211
|
+
const { hydrationData, ...rest } = v
|
|
212
|
+
v = rest
|
|
213
|
+
}
|
|
214
|
+
setStateWithReconciliation(v)
|
|
230
215
|
},
|
|
231
216
|
] as Signal<T>
|
|
232
217
|
}
|
|
@@ -269,9 +254,8 @@ export function createBaseQuery<
|
|
|
269
254
|
return reject(observerResult.error)
|
|
270
255
|
}
|
|
271
256
|
if (!observerResult.isLoading) {
|
|
272
|
-
const query = obs.getCurrentQuery()
|
|
273
257
|
resolver = null
|
|
274
|
-
return resolve(
|
|
258
|
+
return resolve(observerResult)
|
|
275
259
|
}
|
|
276
260
|
|
|
277
261
|
setStateWithReconciliation(observerResult)
|
|
@@ -293,15 +277,10 @@ export function createBaseQuery<
|
|
|
293
277
|
* Note that this is only invoked on the client, for queries that were originally run on the server.
|
|
294
278
|
*/
|
|
295
279
|
onHydrated(_k, info) {
|
|
296
|
-
if (info.value) {
|
|
280
|
+
if (info.value && 'hydrationData' in info.value) {
|
|
297
281
|
hydrate(client(), {
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
queryKey: initialOptions.queryKey,
|
|
301
|
-
queryHash: initialOptions.queryHash,
|
|
302
|
-
state: info.value,
|
|
303
|
-
},
|
|
304
|
-
],
|
|
282
|
+
// @ts-expect-error - hydrationData is not correctly typed internally
|
|
283
|
+
queries: [{ ...info.value.hydrationData }],
|
|
305
284
|
})
|
|
306
285
|
}
|
|
307
286
|
|
|
@@ -376,6 +355,7 @@ export function createBaseQuery<
|
|
|
376
355
|
([obs, opts]) => {
|
|
377
356
|
obs.setOptions(opts)
|
|
378
357
|
setStateWithReconciliation(obs.getOptimisticResult(opts))
|
|
358
|
+
refetch()
|
|
379
359
|
},
|
|
380
360
|
{ defer: true },
|
|
381
361
|
),
|