@trpc/react-query 11.0.0-alpha-tmp-subscription-connection-state.488 → 11.0.0-alpha-tmp-12-06-react.665
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/dist/bundle-analysis.json +59 -76
- package/dist/createTRPCReact.d.ts +47 -17
- package/dist/createTRPCReact.d.ts.map +1 -1
- package/dist/internals/context.d.ts +43 -21
- package/dist/internals/context.d.ts.map +1 -1
- package/dist/internals/getQueryKey.d.ts +2 -2
- package/dist/internals/getQueryKey.js +3 -3
- package/dist/internals/getQueryKey.mjs +3 -3
- package/dist/internals/trpcResult.d.ts +18 -0
- package/dist/internals/trpcResult.d.ts.map +1 -0
- package/dist/internals/trpcResult.js +63 -0
- package/dist/internals/trpcResult.mjs +40 -0
- package/dist/internals/useQueries.d.ts +1 -1
- package/dist/internals/useQueries.d.ts.map +1 -1
- package/dist/rsc.d.ts +1 -1
- package/dist/rsc.d.ts.map +1 -1
- package/dist/rsc.js +4 -4
- package/dist/rsc.mjs +4 -4
- package/dist/server/ssgProxy.d.ts +7 -24
- package/dist/server/ssgProxy.d.ts.map +1 -1
- package/dist/server/ssgProxy.js +21 -4
- package/dist/server/ssgProxy.mjs +21 -4
- package/dist/shared/hooks/createHooksInternal.d.ts +4 -2
- package/dist/shared/hooks/createHooksInternal.d.ts.map +1 -1
- package/dist/shared/hooks/createHooksInternal.js +160 -93
- package/dist/shared/hooks/createHooksInternal.mjs +156 -89
- package/dist/shared/hooks/types.d.ts +38 -159
- package/dist/shared/hooks/types.d.ts.map +1 -1
- package/dist/shared/index.js +0 -7
- package/dist/shared/index.mjs +0 -1
- package/dist/shared/polymorphism/mutationLike.d.ts.map +1 -1
- package/dist/shared/polymorphism/queryLike.d.ts.map +1 -1
- package/dist/shared/polymorphism/routerLike.d.ts.map +1 -1
- package/dist/shared/proxy/decorationProxy.js +1 -1
- package/dist/shared/proxy/decorationProxy.mjs +1 -1
- package/dist/shared/proxy/useQueriesProxy.d.ts.map +1 -1
- package/dist/shared/proxy/utilsProxy.d.ts +45 -20
- package/dist/shared/proxy/utilsProxy.d.ts.map +1 -1
- package/dist/shared/proxy/utilsProxy.js +4 -0
- package/dist/shared/proxy/utilsProxy.mjs +4 -0
- package/dist/shared/types.d.ts +60 -2
- package/dist/shared/types.d.ts.map +1 -1
- package/dist/utils/createUtilityFunctions.d.ts +2 -2
- package/dist/utils/createUtilityFunctions.d.ts.map +1 -1
- package/dist/utils/createUtilityFunctions.js +69 -3
- package/dist/utils/createUtilityFunctions.mjs +69 -3
- package/dist/utils/inferReactQueryProcedure.d.ts +2 -2
- package/dist/utils/inferReactQueryProcedure.d.ts.map +1 -1
- package/package.json +22 -19
- package/src/createTRPCReact.tsx +276 -65
- package/src/internals/context.tsx +105 -24
- package/src/internals/getQueryKey.ts +2 -2
- package/src/internals/trpcResult.ts +55 -0
- package/src/internals/useQueries.ts +36 -31
- package/src/rsc.tsx +6 -6
- package/src/server/ssgProxy.ts +23 -66
- package/src/shared/hooks/createHooksInternal.tsx +222 -151
- package/src/shared/hooks/types.ts +64 -348
- package/src/shared/polymorphism/mutationLike.ts +8 -6
- package/src/shared/polymorphism/queryLike.ts +12 -14
- package/src/shared/polymorphism/routerLike.ts +4 -4
- package/src/shared/proxy/useQueriesProxy.ts +4 -4
- package/src/shared/proxy/utilsProxy.ts +153 -25
- package/src/shared/types.ts +229 -1
- package/src/utils/createUtilityFunctions.ts +90 -2
- package/src/utils/inferReactQueryProcedure.ts +8 -6
- package/dist/internals/useHookResult.d.ts +0 -8
- package/dist/internals/useHookResult.d.ts.map +0 -1
- package/dist/internals/useHookResult.js +0 -35
- package/dist/internals/useHookResult.mjs +0 -14
- package/dist/shared/hooks/types.js +0 -133
- package/dist/shared/hooks/types.mjs +0 -126
- package/src/internals/useHookResult.ts +0 -17
|
@@ -7,10 +7,9 @@ var React = require('react');
|
|
|
7
7
|
var context = require('../../internals/context.js');
|
|
8
8
|
var getClientArgs = require('../../internals/getClientArgs.js');
|
|
9
9
|
var getQueryKey = require('../../internals/getQueryKey.js');
|
|
10
|
-
var
|
|
10
|
+
var trpcResult = require('../../internals/trpcResult.js');
|
|
11
11
|
var createUtilityFunctions = require('../../utils/createUtilityFunctions.js');
|
|
12
12
|
var useQueriesProxy = require('../proxy/useQueriesProxy.js');
|
|
13
|
-
var types = require('./types.js');
|
|
14
13
|
|
|
15
14
|
function _interopNamespaceDefault(e) {
|
|
16
15
|
var n = Object.create(null);
|
|
@@ -49,7 +48,7 @@ const trackResult = (result, onTrackResult)=>{
|
|
|
49
48
|
return client.createTRPCUntypedClient(opts);
|
|
50
49
|
};
|
|
51
50
|
const TRPCProvider = (props)=>{
|
|
52
|
-
const { abortOnUnmount =false
|
|
51
|
+
const { abortOnUnmount = false, client, queryClient, ssrContext } = props;
|
|
53
52
|
const [ssrState, setSSRState] = React__namespace.useState(props.ssrState ?? false);
|
|
54
53
|
const fns = React__namespace.useMemo(()=>createUtilityFunctions.createUtilityFunctions({
|
|
55
54
|
client,
|
|
@@ -91,9 +90,9 @@ const trackResult = (result, onTrackResult)=>{
|
|
|
91
90
|
}
|
|
92
91
|
/**
|
|
93
92
|
* Hack to make sure errors return `status`='error` when doing SSR
|
|
94
|
-
* @
|
|
93
|
+
* @see https://github.com/trpc/trpc/pull/1645
|
|
95
94
|
*/ function useSSRQueryOptionsIfNeeded(queryKey, opts) {
|
|
96
|
-
const { queryClient
|
|
95
|
+
const { queryClient, ssrState } = useContext();
|
|
97
96
|
return ssrState && ssrState !== 'mounted' && queryClient.getQueryCache().find({
|
|
98
97
|
queryKey
|
|
99
98
|
})?.state.status === 'error' ? {
|
|
@@ -103,7 +102,7 @@ const trackResult = (result, onTrackResult)=>{
|
|
|
103
102
|
}
|
|
104
103
|
function useQuery(path, input, opts) {
|
|
105
104
|
const context = useContext();
|
|
106
|
-
const { abortOnUnmount
|
|
105
|
+
const { abortOnUnmount, client, ssrState, queryClient, prefetchQuery } = context;
|
|
107
106
|
const queryKey = getQueryKey.getQueryKeyInternal(path, input, 'query');
|
|
108
107
|
const defaultOpts = queryClient.getQueryDefaults(queryKey);
|
|
109
108
|
const isInputSkipToken = input === reactQuery.skipToken;
|
|
@@ -134,33 +133,37 @@ const trackResult = (result, onTrackResult)=>{
|
|
|
134
133
|
};
|
|
135
134
|
const result = await client.query(...getClientArgs.getClientArgs(queryKey, actualOpts));
|
|
136
135
|
if (unstableCoreDoNotImport.isAsyncIterable(result)) {
|
|
137
|
-
|
|
138
|
-
const query = queryCache.build(queryFunctionContext.queryKey, {
|
|
139
|
-
queryKey
|
|
140
|
-
});
|
|
141
|
-
query.setState({
|
|
142
|
-
data: [],
|
|
143
|
-
status: 'success'
|
|
144
|
-
});
|
|
145
|
-
const aggregate = [];
|
|
146
|
-
for await (const value of result){
|
|
147
|
-
aggregate.push(value);
|
|
148
|
-
query.setState({
|
|
149
|
-
data: [
|
|
150
|
-
...aggregate
|
|
151
|
-
]
|
|
152
|
-
});
|
|
153
|
-
}
|
|
154
|
-
return aggregate;
|
|
136
|
+
return trpcResult.buildQueryFromAsyncIterable(result, queryClient, queryKey);
|
|
155
137
|
}
|
|
156
138
|
return result;
|
|
157
139
|
}
|
|
158
140
|
}, queryClient);
|
|
159
|
-
hook.trpc =
|
|
141
|
+
hook.trpc = trpcResult.useHookResult({
|
|
160
142
|
path
|
|
161
143
|
});
|
|
162
144
|
return hook;
|
|
163
145
|
}
|
|
146
|
+
function usePrefetchQuery(path, input, opts) {
|
|
147
|
+
const context = useContext();
|
|
148
|
+
const queryKey = getQueryKey.getQueryKeyInternal(path, input, 'query');
|
|
149
|
+
const isInputSkipToken = input === reactQuery.skipToken;
|
|
150
|
+
const shouldAbortOnUnmount = opts?.trpc?.abortOnUnmount ?? config?.abortOnUnmount ?? context.abortOnUnmount;
|
|
151
|
+
reactQuery.usePrefetchQuery({
|
|
152
|
+
...opts,
|
|
153
|
+
queryKey: queryKey,
|
|
154
|
+
queryFn: isInputSkipToken ? input : (queryFunctionContext)=>{
|
|
155
|
+
const actualOpts = {
|
|
156
|
+
trpc: {
|
|
157
|
+
...opts?.trpc,
|
|
158
|
+
...shouldAbortOnUnmount ? {
|
|
159
|
+
signal: queryFunctionContext.signal
|
|
160
|
+
} : {}
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
return context.client.query(...getClientArgs.getClientArgs(queryKey, actualOpts));
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
}
|
|
164
167
|
function useSuspenseQuery(path, input, opts) {
|
|
165
168
|
const context = useContext();
|
|
166
169
|
const queryKey = getQueryKey.getQueryKeyInternal(path, input, 'query');
|
|
@@ -170,7 +173,9 @@ const trackResult = (result, onTrackResult)=>{
|
|
|
170
173
|
queryKey: queryKey,
|
|
171
174
|
queryFn: (queryFunctionContext)=>{
|
|
172
175
|
const actualOpts = {
|
|
176
|
+
...opts,
|
|
173
177
|
trpc: {
|
|
178
|
+
...opts?.trpc,
|
|
174
179
|
...shouldAbortOnUnmount ? {
|
|
175
180
|
signal: queryFunctionContext.signal
|
|
176
181
|
} : {
|
|
@@ -181,7 +186,7 @@ const trackResult = (result, onTrackResult)=>{
|
|
|
181
186
|
return context.client.query(...getClientArgs.getClientArgs(queryKey, actualOpts));
|
|
182
187
|
}
|
|
183
188
|
}, context.queryClient);
|
|
184
|
-
hook.trpc =
|
|
189
|
+
hook.trpc = trpcResult.useHookResult({
|
|
185
190
|
path
|
|
186
191
|
});
|
|
187
192
|
return [
|
|
@@ -190,8 +195,7 @@ const trackResult = (result, onTrackResult)=>{
|
|
|
190
195
|
];
|
|
191
196
|
}
|
|
192
197
|
function useMutation(path, opts) {
|
|
193
|
-
const { client
|
|
194
|
-
const queryClient = reactQuery.useQueryClient();
|
|
198
|
+
const { client, queryClient } = useContext();
|
|
195
199
|
const mutationKey = getQueryKey.getMutationKeyInternal(path);
|
|
196
200
|
const defaultOpts = queryClient.defaultMutationOptions(queryClient.getMutationDefaults(mutationKey));
|
|
197
201
|
const hook = reactQuery.useMutation({
|
|
@@ -214,7 +218,7 @@ const trackResult = (result, onTrackResult)=>{
|
|
|
214
218
|
});
|
|
215
219
|
}
|
|
216
220
|
}, queryClient);
|
|
217
|
-
hook.trpc =
|
|
221
|
+
hook.trpc = trpcResult.useHookResult({
|
|
218
222
|
path
|
|
219
223
|
});
|
|
220
224
|
return hook;
|
|
@@ -222,37 +226,18 @@ const trackResult = (result, onTrackResult)=>{
|
|
|
222
226
|
/* istanbul ignore next -- @preserve */ function useSubscription(path, input, opts) {
|
|
223
227
|
const enabled = opts?.enabled ?? input !== reactQuery.skipToken;
|
|
224
228
|
const queryKey = reactQuery.hashKey(getQueryKey.getQueryKeyInternal(path, input, 'any'));
|
|
229
|
+
const { client } = useContext();
|
|
230
|
+
const optsRef = React__namespace.useRef(opts);
|
|
231
|
+
optsRef.current = opts;
|
|
225
232
|
const trackedProps = React__namespace.useRef(new Set([]));
|
|
226
233
|
const addTrackedProp = React__namespace.useCallback((key)=>{
|
|
227
234
|
trackedProps.current.add(key);
|
|
228
235
|
}, []);
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
const updateSubscriptionState = React__namespace.useCallback((opts)=>{
|
|
235
|
-
const oldResult = currentResult.current;
|
|
236
|
-
const newResult = typeof opts === 'function' ? opts(currentResult.current) : opts;
|
|
237
|
-
currentResult.current = newResult;
|
|
238
|
-
let shouldUpdate = false;
|
|
239
|
-
for (const key of trackedProps.current){
|
|
240
|
-
if (oldResult[key] !== newResult[key]) {
|
|
241
|
-
shouldUpdate = true;
|
|
242
|
-
break;
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
if (shouldUpdate) {
|
|
246
|
-
setSubscriptionState(trackResult(newResult, addTrackedProp));
|
|
247
|
-
return;
|
|
248
|
-
}
|
|
249
|
-
}, [
|
|
250
|
-
addTrackedProp
|
|
251
|
-
]);
|
|
252
|
-
const { client } = useContext();
|
|
253
|
-
const optsRef = React__namespace.useRef(opts);
|
|
254
|
-
optsRef.current = opts;
|
|
255
|
-
React__namespace.useEffect(()=>{
|
|
236
|
+
const currentSubscriptionRef = React__namespace.useRef(null);
|
|
237
|
+
const reset = React__namespace.useCallback(()=>{
|
|
238
|
+
// unsubscribe from the previous subscription
|
|
239
|
+
currentSubscriptionRef.current?.();
|
|
240
|
+
updateState(getInitialState);
|
|
256
241
|
if (!enabled) {
|
|
257
242
|
return;
|
|
258
243
|
}
|
|
@@ -261,60 +246,107 @@ const trackResult = (result, onTrackResult)=>{
|
|
|
261
246
|
onStarted: ()=>{
|
|
262
247
|
if (!isStopped) {
|
|
263
248
|
optsRef.current.onStarted?.();
|
|
249
|
+
updateState((prev)=>({
|
|
250
|
+
...prev,
|
|
251
|
+
status: 'pending',
|
|
252
|
+
error: null
|
|
253
|
+
}));
|
|
264
254
|
}
|
|
265
255
|
},
|
|
266
256
|
onData: (data)=>{
|
|
267
257
|
if (!isStopped) {
|
|
268
|
-
optsRef.current.onData(data);
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
258
|
+
optsRef.current.onData?.(data);
|
|
259
|
+
updateState((prev)=>({
|
|
260
|
+
...prev,
|
|
261
|
+
status: 'pending',
|
|
262
|
+
data,
|
|
263
|
+
error: null
|
|
264
|
+
}));
|
|
275
265
|
}
|
|
276
266
|
},
|
|
277
|
-
onError: (
|
|
267
|
+
onError: (error)=>{
|
|
278
268
|
if (!isStopped) {
|
|
279
|
-
optsRef.current.onError?.(
|
|
269
|
+
optsRef.current.onError?.(error);
|
|
270
|
+
updateState((prev)=>({
|
|
271
|
+
...prev,
|
|
272
|
+
status: 'error',
|
|
273
|
+
error
|
|
274
|
+
}));
|
|
280
275
|
}
|
|
281
276
|
},
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
}
|
|
293
|
-
if (state.state === 'pending') {
|
|
294
|
-
updateSubscriptionState((prev)=>types.getPendingResult(prev));
|
|
295
|
-
}
|
|
296
|
-
if (state.state === 'error') {
|
|
297
|
-
updateSubscriptionState((prev)=>{
|
|
298
|
-
return types.getErrorResult(prev, state.data);
|
|
299
|
-
});
|
|
300
|
-
}
|
|
277
|
+
onConnectionStateChange: (result)=>{
|
|
278
|
+
const delta = {
|
|
279
|
+
status: result.state,
|
|
280
|
+
error: result.error
|
|
281
|
+
};
|
|
282
|
+
updateState((prev)=>{
|
|
283
|
+
return {
|
|
284
|
+
...prev,
|
|
285
|
+
...delta
|
|
286
|
+
};
|
|
287
|
+
});
|
|
301
288
|
}
|
|
302
289
|
});
|
|
303
|
-
|
|
304
|
-
return ()=>{
|
|
290
|
+
currentSubscriptionRef.current = ()=>{
|
|
305
291
|
isStopped = true;
|
|
306
292
|
subscription.unsubscribe();
|
|
307
|
-
updateSubscriptionState(types.getIdleResult());
|
|
308
293
|
};
|
|
309
294
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
310
295
|
}, [
|
|
311
296
|
queryKey,
|
|
312
297
|
enabled
|
|
313
298
|
]);
|
|
314
|
-
|
|
299
|
+
const getInitialState = React__namespace.useCallback(()=>{
|
|
300
|
+
return enabled ? {
|
|
301
|
+
data: undefined,
|
|
302
|
+
error: null,
|
|
303
|
+
status: 'connecting',
|
|
304
|
+
reset
|
|
305
|
+
} : {
|
|
306
|
+
data: undefined,
|
|
307
|
+
error: null,
|
|
308
|
+
status: 'idle',
|
|
309
|
+
reset
|
|
310
|
+
};
|
|
311
|
+
}, [
|
|
312
|
+
enabled,
|
|
313
|
+
reset
|
|
314
|
+
]);
|
|
315
|
+
const resultRef = React__namespace.useRef(getInitialState());
|
|
316
|
+
const [state, setState] = React__namespace.useState(trackResult(resultRef.current, addTrackedProp));
|
|
317
|
+
state.reset = reset;
|
|
318
|
+
const updateState = React__namespace.useCallback((callback)=>{
|
|
319
|
+
const prev = resultRef.current;
|
|
320
|
+
const next = resultRef.current = callback(prev);
|
|
321
|
+
let shouldUpdate = false;
|
|
322
|
+
for (const key of trackedProps.current){
|
|
323
|
+
if (prev[key] !== next[key]) {
|
|
324
|
+
shouldUpdate = true;
|
|
325
|
+
break;
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
if (shouldUpdate) {
|
|
329
|
+
setState(trackResult(next, addTrackedProp));
|
|
330
|
+
}
|
|
331
|
+
}, [
|
|
332
|
+
addTrackedProp
|
|
333
|
+
]);
|
|
334
|
+
React__namespace.useEffect(()=>{
|
|
335
|
+
if (!enabled) {
|
|
336
|
+
return;
|
|
337
|
+
}
|
|
338
|
+
reset();
|
|
339
|
+
return ()=>{
|
|
340
|
+
currentSubscriptionRef.current?.();
|
|
341
|
+
};
|
|
342
|
+
}, [
|
|
343
|
+
reset,
|
|
344
|
+
enabled
|
|
345
|
+
]);
|
|
346
|
+
return state;
|
|
315
347
|
}
|
|
316
348
|
function useInfiniteQuery(path, input, opts) {
|
|
317
|
-
const { client
|
|
349
|
+
const { client, ssrState, prefetchInfiniteQuery, queryClient, abortOnUnmount } = useContext();
|
|
318
350
|
const queryKey = getQueryKey.getQueryKeyInternal(path, input, 'infinite');
|
|
319
351
|
const defaultOpts = queryClient.getQueryDefaults(queryKey);
|
|
320
352
|
const isInputSkipToken = input === reactQuery.skipToken;
|
|
@@ -355,11 +387,43 @@ const trackResult = (result, onTrackResult)=>{
|
|
|
355
387
|
}));
|
|
356
388
|
}
|
|
357
389
|
}, queryClient);
|
|
358
|
-
hook.trpc =
|
|
390
|
+
hook.trpc = trpcResult.useHookResult({
|
|
359
391
|
path
|
|
360
392
|
});
|
|
361
393
|
return hook;
|
|
362
394
|
}
|
|
395
|
+
function usePrefetchInfiniteQuery(path, input, opts) {
|
|
396
|
+
const context = useContext();
|
|
397
|
+
const queryKey = getQueryKey.getQueryKeyInternal(path, input, 'infinite');
|
|
398
|
+
const defaultOpts = context.queryClient.getQueryDefaults(queryKey);
|
|
399
|
+
const isInputSkipToken = input === reactQuery.skipToken;
|
|
400
|
+
const ssrOpts = useSSRQueryOptionsIfNeeded(queryKey, {
|
|
401
|
+
...defaultOpts,
|
|
402
|
+
...opts
|
|
403
|
+
});
|
|
404
|
+
// request option should take priority over global
|
|
405
|
+
const shouldAbortOnUnmount = opts?.trpc?.abortOnUnmount ?? context.abortOnUnmount;
|
|
406
|
+
reactQuery.usePrefetchInfiniteQuery({
|
|
407
|
+
...opts,
|
|
408
|
+
initialPageParam: opts.initialCursor ?? null,
|
|
409
|
+
queryKey,
|
|
410
|
+
queryFn: isInputSkipToken ? input : (queryFunctionContext)=>{
|
|
411
|
+
const actualOpts = {
|
|
412
|
+
...ssrOpts,
|
|
413
|
+
trpc: {
|
|
414
|
+
...ssrOpts?.trpc,
|
|
415
|
+
...shouldAbortOnUnmount ? {
|
|
416
|
+
signal: queryFunctionContext.signal
|
|
417
|
+
} : {}
|
|
418
|
+
}
|
|
419
|
+
};
|
|
420
|
+
return context.client.query(...getClientArgs.getClientArgs(queryKey, actualOpts, {
|
|
421
|
+
pageParam: queryFunctionContext.pageParam ?? opts.initialCursor,
|
|
422
|
+
direction: queryFunctionContext.direction
|
|
423
|
+
}));
|
|
424
|
+
}
|
|
425
|
+
});
|
|
426
|
+
}
|
|
363
427
|
function useSuspenseInfiniteQuery(path, input, opts) {
|
|
364
428
|
const context = useContext();
|
|
365
429
|
const queryKey = getQueryKey.getQueryKeyInternal(path, input, 'infinite');
|
|
@@ -390,7 +454,7 @@ const trackResult = (result, onTrackResult)=>{
|
|
|
390
454
|
}));
|
|
391
455
|
}
|
|
392
456
|
}, context.queryClient);
|
|
393
|
-
hook.trpc =
|
|
457
|
+
hook.trpc = trpcResult.useHookResult({
|
|
394
458
|
path
|
|
395
459
|
});
|
|
396
460
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
@@ -400,7 +464,7 @@ const trackResult = (result, onTrackResult)=>{
|
|
|
400
464
|
];
|
|
401
465
|
}
|
|
402
466
|
const useQueries = (queriesCallback)=>{
|
|
403
|
-
const { ssrState
|
|
467
|
+
const { ssrState, queryClient, prefetchQuery, client } = useContext();
|
|
404
468
|
const proxy = useQueriesProxy.createUseQueries(client);
|
|
405
469
|
const queries = queriesCallback(proxy);
|
|
406
470
|
if (typeof window === 'undefined' && ssrState === 'prepass') {
|
|
@@ -421,12 +485,13 @@ const trackResult = (result, onTrackResult)=>{
|
|
|
421
485
|
}, queryClient);
|
|
422
486
|
};
|
|
423
487
|
const useSuspenseQueries = (queriesCallback)=>{
|
|
424
|
-
const { queryClient
|
|
488
|
+
const { queryClient, client } = useContext();
|
|
425
489
|
const proxy = useQueriesProxy.createUseQueries(client);
|
|
426
490
|
const queries = queriesCallback(proxy);
|
|
427
491
|
const hook = reactQuery.useSuspenseQueries({
|
|
428
492
|
queries: queries.map((query)=>({
|
|
429
493
|
...query,
|
|
494
|
+
queryFn: query.queryFn,
|
|
430
495
|
queryKey: query.queryKey
|
|
431
496
|
}))
|
|
432
497
|
}, queryClient);
|
|
@@ -441,12 +506,14 @@ const trackResult = (result, onTrackResult)=>{
|
|
|
441
506
|
useContext,
|
|
442
507
|
useUtils: useContext,
|
|
443
508
|
useQuery,
|
|
509
|
+
usePrefetchQuery,
|
|
444
510
|
useSuspenseQuery,
|
|
445
511
|
useQueries,
|
|
446
512
|
useSuspenseQueries,
|
|
447
513
|
useMutation,
|
|
448
514
|
useSubscription,
|
|
449
515
|
useInfiniteQuery,
|
|
516
|
+
usePrefetchInfiniteQuery,
|
|
450
517
|
useSuspenseInfiniteQuery
|
|
451
518
|
};
|
|
452
519
|
}
|