@trpc/react-query 10.8.1 → 10.8.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/dist/{createHooksInternal-d8e5577b.js → createHooksInternal-57a3cf21.js} +108 -77
- package/dist/{createHooksInternal-9c1f8ad9.mjs → createHooksInternal-b83f2ee6.mjs} +108 -77
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/dist/shared/hooks/createHooksInternal.d.ts.map +1 -1
- package/dist/shared/index.js +1 -1
- package/dist/shared/index.mjs +1 -1
- package/dist/ssg/index.js +44 -32
- package/dist/ssg/index.mjs +44 -32
- package/package.json +6 -6
- package/src/shared/hooks/createHooksInternal.tsx +69 -61
- package/src/shared/proxy/useQueriesProxy.ts +1 -1
- package/src/ssg/ssg.ts +16 -16
|
@@ -143,7 +143,7 @@ const TRPCContext = /*#__PURE__*/ React.createContext(null);
|
|
|
143
143
|
queryFn: ()=>{
|
|
144
144
|
return client.query(path, input);
|
|
145
145
|
},
|
|
146
|
-
...rest[
|
|
146
|
+
...rest[0]
|
|
147
147
|
};
|
|
148
148
|
return options;
|
|
149
149
|
});
|
|
@@ -199,69 +199,95 @@ function getClientArgs(pathAndInput, opts) {
|
|
|
199
199
|
ssrContext: ssrContext || null,
|
|
200
200
|
ssrState,
|
|
201
201
|
fetchQuery: React.useCallback((pathAndInput, opts)=>{
|
|
202
|
-
return queryClient.fetchQuery(
|
|
202
|
+
return queryClient.fetchQuery({
|
|
203
|
+
...opts,
|
|
204
|
+
queryKey: getArrayQueryKey.getArrayQueryKey(pathAndInput, 'query'),
|
|
205
|
+
queryFn: ()=>client.query(...getClientArgs(pathAndInput, opts))
|
|
206
|
+
});
|
|
203
207
|
}, [
|
|
204
208
|
client,
|
|
205
209
|
queryClient
|
|
206
210
|
]),
|
|
207
211
|
fetchInfiniteQuery: React.useCallback((pathAndInput, opts)=>{
|
|
208
|
-
return queryClient.fetchInfiniteQuery(
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
212
|
+
return queryClient.fetchInfiniteQuery({
|
|
213
|
+
...opts,
|
|
214
|
+
queryKey: getArrayQueryKey.getArrayQueryKey(pathAndInput, 'infinite'),
|
|
215
|
+
queryFn: ({ pageParam })=>{
|
|
216
|
+
const [path, input] = pathAndInput;
|
|
217
|
+
const actualInput = {
|
|
218
|
+
...input,
|
|
219
|
+
cursor: pageParam
|
|
220
|
+
};
|
|
221
|
+
return client.query(...getClientArgs([
|
|
222
|
+
path,
|
|
223
|
+
actualInput
|
|
224
|
+
], opts));
|
|
225
|
+
}
|
|
226
|
+
});
|
|
219
227
|
}, [
|
|
220
228
|
client,
|
|
221
229
|
queryClient
|
|
222
230
|
]),
|
|
223
231
|
prefetchQuery: React.useCallback((pathAndInput, opts)=>{
|
|
224
|
-
return queryClient.prefetchQuery(
|
|
232
|
+
return queryClient.prefetchQuery({
|
|
233
|
+
...opts,
|
|
234
|
+
queryKey: getArrayQueryKey.getArrayQueryKey(pathAndInput, 'query'),
|
|
235
|
+
queryFn: ()=>client.query(...getClientArgs(pathAndInput, opts))
|
|
236
|
+
});
|
|
225
237
|
}, [
|
|
226
238
|
client,
|
|
227
239
|
queryClient
|
|
228
240
|
]),
|
|
229
241
|
prefetchInfiniteQuery: React.useCallback((pathAndInput, opts)=>{
|
|
230
|
-
return queryClient.prefetchInfiniteQuery(
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
242
|
+
return queryClient.prefetchInfiniteQuery({
|
|
243
|
+
...opts,
|
|
244
|
+
queryKey: getArrayQueryKey.getArrayQueryKey(pathAndInput, 'infinite'),
|
|
245
|
+
queryFn: ({ pageParam })=>{
|
|
246
|
+
const [path, input] = pathAndInput;
|
|
247
|
+
const actualInput = {
|
|
248
|
+
...input,
|
|
249
|
+
cursor: pageParam
|
|
250
|
+
};
|
|
251
|
+
return client.query(...getClientArgs([
|
|
252
|
+
path,
|
|
253
|
+
actualInput
|
|
254
|
+
], opts));
|
|
255
|
+
}
|
|
256
|
+
});
|
|
241
257
|
}, [
|
|
242
258
|
client,
|
|
243
259
|
queryClient
|
|
244
260
|
]),
|
|
245
|
-
invalidateQueries: React.useCallback((
|
|
246
|
-
|
|
247
|
-
|
|
261
|
+
invalidateQueries: React.useCallback((queryKey, filters, options)=>{
|
|
262
|
+
return queryClient.invalidateQueries({
|
|
263
|
+
...filters,
|
|
264
|
+
queryKey: getArrayQueryKey.getArrayQueryKey(queryKey, 'any')
|
|
265
|
+
}, options);
|
|
248
266
|
}, [
|
|
249
267
|
queryClient
|
|
250
268
|
]),
|
|
251
269
|
resetQueries: React.useCallback((...args)=>{
|
|
252
|
-
const [queryKey,
|
|
253
|
-
return queryClient.resetQueries(
|
|
270
|
+
const [queryKey, filters, options] = args;
|
|
271
|
+
return queryClient.resetQueries({
|
|
272
|
+
...filters,
|
|
273
|
+
queryKey: getArrayQueryKey.getArrayQueryKey(queryKey, 'any')
|
|
274
|
+
}, options);
|
|
254
275
|
}, [
|
|
255
276
|
queryClient
|
|
256
277
|
]),
|
|
257
278
|
refetchQueries: React.useCallback((...args)=>{
|
|
258
|
-
const [queryKey,
|
|
259
|
-
return queryClient.refetchQueries(
|
|
279
|
+
const [queryKey, filters, options] = args;
|
|
280
|
+
return queryClient.refetchQueries({
|
|
281
|
+
...filters,
|
|
282
|
+
queryKey: getArrayQueryKey.getArrayQueryKey(queryKey, 'any')
|
|
283
|
+
}, options);
|
|
260
284
|
}, [
|
|
261
285
|
queryClient
|
|
262
286
|
]),
|
|
263
287
|
cancelQuery: React.useCallback((pathAndInput)=>{
|
|
264
|
-
return queryClient.cancelQueries(
|
|
288
|
+
return queryClient.cancelQueries({
|
|
289
|
+
queryKey: getArrayQueryKey.getArrayQueryKey(pathAndInput, 'any')
|
|
290
|
+
});
|
|
265
291
|
}, [
|
|
266
292
|
queryClient
|
|
267
293
|
]),
|
|
@@ -314,20 +340,22 @@ function getClientArgs(pathAndInput, opts) {
|
|
|
314
340
|
const ssrOpts = useSSRQueryOptionsIfNeeded(pathAndInput, 'query', opts);
|
|
315
341
|
// request option should take priority over global
|
|
316
342
|
const shouldAbortOnUnmount = opts?.trpc?.abortOnUnmount ?? abortOnUnmount;
|
|
317
|
-
const hook = reactQuery.useQuery(
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
...
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
343
|
+
const hook = reactQuery.useQuery({
|
|
344
|
+
...ssrOpts,
|
|
345
|
+
queryKey: getArrayQueryKey.getArrayQueryKey(pathAndInput, 'query'),
|
|
346
|
+
queryFn: (queryFunctionContext)=>{
|
|
347
|
+
const actualOpts = {
|
|
348
|
+
...ssrOpts,
|
|
349
|
+
trpc: {
|
|
350
|
+
...ssrOpts?.trpc,
|
|
351
|
+
...shouldAbortOnUnmount ? {
|
|
352
|
+
signal: queryFunctionContext.signal
|
|
353
|
+
} : {}
|
|
354
|
+
}
|
|
355
|
+
};
|
|
356
|
+
return client.query(...getClientArgs(pathAndInput, actualOpts));
|
|
357
|
+
},
|
|
358
|
+
context: ReactQueryContext
|
|
331
359
|
});
|
|
332
360
|
hook.trpc = useHookResult({
|
|
333
361
|
path: pathAndInput[0]
|
|
@@ -340,15 +368,16 @@ function getClientArgs(pathAndInput, opts) {
|
|
|
340
368
|
const queryClient = reactQuery.useQueryClient({
|
|
341
369
|
context: ReactQueryContext
|
|
342
370
|
});
|
|
343
|
-
const hook = reactQuery.useMutation(
|
|
344
|
-
const actualPath = Array.isArray(path) ? path[0] : path;
|
|
345
|
-
return client.mutation(...getClientArgs([
|
|
346
|
-
actualPath,
|
|
347
|
-
input
|
|
348
|
-
], opts));
|
|
349
|
-
}, {
|
|
350
|
-
context: ReactQueryContext,
|
|
371
|
+
const hook = reactQuery.useMutation({
|
|
351
372
|
...opts,
|
|
373
|
+
mutationFn: (input)=>{
|
|
374
|
+
const actualPath = Array.isArray(path) ? path[0] : path;
|
|
375
|
+
return client.mutation(...getClientArgs([
|
|
376
|
+
actualPath,
|
|
377
|
+
input
|
|
378
|
+
], opts));
|
|
379
|
+
},
|
|
380
|
+
context: ReactQueryContext,
|
|
352
381
|
onSuccess (...args) {
|
|
353
382
|
const originalFn = ()=>opts?.onSuccess?.(...args);
|
|
354
383
|
return mutationSuccessOverride({
|
|
@@ -410,28 +439,30 @@ function getClientArgs(pathAndInput, opts) {
|
|
|
410
439
|
const ssrOpts = useSSRQueryOptionsIfNeeded(pathAndInput, 'infinite', opts);
|
|
411
440
|
// request option should take priority over global
|
|
412
441
|
const shouldAbortOnUnmount = opts?.trpc?.abortOnUnmount ?? abortOnUnmount;
|
|
413
|
-
const hook = reactQuery.useInfiniteQuery(
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
...
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
442
|
+
const hook = reactQuery.useInfiniteQuery({
|
|
443
|
+
...ssrOpts,
|
|
444
|
+
queryKey: getArrayQueryKey.getArrayQueryKey(pathAndInput, 'infinite'),
|
|
445
|
+
queryFn: (queryFunctionContext)=>{
|
|
446
|
+
const actualOpts = {
|
|
447
|
+
...ssrOpts,
|
|
448
|
+
trpc: {
|
|
449
|
+
...ssrOpts?.trpc,
|
|
450
|
+
...shouldAbortOnUnmount ? {
|
|
451
|
+
signal: queryFunctionContext.signal
|
|
452
|
+
} : {}
|
|
453
|
+
}
|
|
454
|
+
};
|
|
455
|
+
const actualInput = {
|
|
456
|
+
...input ?? {},
|
|
457
|
+
cursor: queryFunctionContext.pageParam
|
|
458
|
+
};
|
|
459
|
+
// FIXME as any shouldn't be needed as client should be untyped too
|
|
460
|
+
return client.query(...getClientArgs([
|
|
461
|
+
path,
|
|
462
|
+
actualInput
|
|
463
|
+
], actualOpts));
|
|
464
|
+
},
|
|
465
|
+
context: ReactQueryContext
|
|
435
466
|
});
|
|
436
467
|
hook.trpc = useHookResult({
|
|
437
468
|
path
|
|
@@ -137,7 +137,7 @@ const TRPCContext = /*#__PURE__*/ createContext(null);
|
|
|
137
137
|
queryFn: ()=>{
|
|
138
138
|
return client.query(path, input);
|
|
139
139
|
},
|
|
140
|
-
...rest[
|
|
140
|
+
...rest[0]
|
|
141
141
|
};
|
|
142
142
|
return options;
|
|
143
143
|
});
|
|
@@ -193,69 +193,95 @@ function getClientArgs(pathAndInput, opts) {
|
|
|
193
193
|
ssrContext: ssrContext || null,
|
|
194
194
|
ssrState,
|
|
195
195
|
fetchQuery: useCallback((pathAndInput, opts)=>{
|
|
196
|
-
return queryClient.fetchQuery(
|
|
196
|
+
return queryClient.fetchQuery({
|
|
197
|
+
...opts,
|
|
198
|
+
queryKey: getArrayQueryKey(pathAndInput, 'query'),
|
|
199
|
+
queryFn: ()=>client.query(...getClientArgs(pathAndInput, opts))
|
|
200
|
+
});
|
|
197
201
|
}, [
|
|
198
202
|
client,
|
|
199
203
|
queryClient
|
|
200
204
|
]),
|
|
201
205
|
fetchInfiniteQuery: useCallback((pathAndInput, opts)=>{
|
|
202
|
-
return queryClient.fetchInfiniteQuery(
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
206
|
+
return queryClient.fetchInfiniteQuery({
|
|
207
|
+
...opts,
|
|
208
|
+
queryKey: getArrayQueryKey(pathAndInput, 'infinite'),
|
|
209
|
+
queryFn: ({ pageParam })=>{
|
|
210
|
+
const [path, input] = pathAndInput;
|
|
211
|
+
const actualInput = {
|
|
212
|
+
...input,
|
|
213
|
+
cursor: pageParam
|
|
214
|
+
};
|
|
215
|
+
return client.query(...getClientArgs([
|
|
216
|
+
path,
|
|
217
|
+
actualInput
|
|
218
|
+
], opts));
|
|
219
|
+
}
|
|
220
|
+
});
|
|
213
221
|
}, [
|
|
214
222
|
client,
|
|
215
223
|
queryClient
|
|
216
224
|
]),
|
|
217
225
|
prefetchQuery: useCallback((pathAndInput, opts)=>{
|
|
218
|
-
return queryClient.prefetchQuery(
|
|
226
|
+
return queryClient.prefetchQuery({
|
|
227
|
+
...opts,
|
|
228
|
+
queryKey: getArrayQueryKey(pathAndInput, 'query'),
|
|
229
|
+
queryFn: ()=>client.query(...getClientArgs(pathAndInput, opts))
|
|
230
|
+
});
|
|
219
231
|
}, [
|
|
220
232
|
client,
|
|
221
233
|
queryClient
|
|
222
234
|
]),
|
|
223
235
|
prefetchInfiniteQuery: useCallback((pathAndInput, opts)=>{
|
|
224
|
-
return queryClient.prefetchInfiniteQuery(
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
236
|
+
return queryClient.prefetchInfiniteQuery({
|
|
237
|
+
...opts,
|
|
238
|
+
queryKey: getArrayQueryKey(pathAndInput, 'infinite'),
|
|
239
|
+
queryFn: ({ pageParam })=>{
|
|
240
|
+
const [path, input] = pathAndInput;
|
|
241
|
+
const actualInput = {
|
|
242
|
+
...input,
|
|
243
|
+
cursor: pageParam
|
|
244
|
+
};
|
|
245
|
+
return client.query(...getClientArgs([
|
|
246
|
+
path,
|
|
247
|
+
actualInput
|
|
248
|
+
], opts));
|
|
249
|
+
}
|
|
250
|
+
});
|
|
235
251
|
}, [
|
|
236
252
|
client,
|
|
237
253
|
queryClient
|
|
238
254
|
]),
|
|
239
|
-
invalidateQueries: useCallback((
|
|
240
|
-
|
|
241
|
-
|
|
255
|
+
invalidateQueries: useCallback((queryKey, filters, options)=>{
|
|
256
|
+
return queryClient.invalidateQueries({
|
|
257
|
+
...filters,
|
|
258
|
+
queryKey: getArrayQueryKey(queryKey, 'any')
|
|
259
|
+
}, options);
|
|
242
260
|
}, [
|
|
243
261
|
queryClient
|
|
244
262
|
]),
|
|
245
263
|
resetQueries: useCallback((...args)=>{
|
|
246
|
-
const [queryKey,
|
|
247
|
-
return queryClient.resetQueries(
|
|
264
|
+
const [queryKey, filters, options] = args;
|
|
265
|
+
return queryClient.resetQueries({
|
|
266
|
+
...filters,
|
|
267
|
+
queryKey: getArrayQueryKey(queryKey, 'any')
|
|
268
|
+
}, options);
|
|
248
269
|
}, [
|
|
249
270
|
queryClient
|
|
250
271
|
]),
|
|
251
272
|
refetchQueries: useCallback((...args)=>{
|
|
252
|
-
const [queryKey,
|
|
253
|
-
return queryClient.refetchQueries(
|
|
273
|
+
const [queryKey, filters, options] = args;
|
|
274
|
+
return queryClient.refetchQueries({
|
|
275
|
+
...filters,
|
|
276
|
+
queryKey: getArrayQueryKey(queryKey, 'any')
|
|
277
|
+
}, options);
|
|
254
278
|
}, [
|
|
255
279
|
queryClient
|
|
256
280
|
]),
|
|
257
281
|
cancelQuery: useCallback((pathAndInput)=>{
|
|
258
|
-
return queryClient.cancelQueries(
|
|
282
|
+
return queryClient.cancelQueries({
|
|
283
|
+
queryKey: getArrayQueryKey(pathAndInput, 'any')
|
|
284
|
+
});
|
|
259
285
|
}, [
|
|
260
286
|
queryClient
|
|
261
287
|
]),
|
|
@@ -308,20 +334,22 @@ function getClientArgs(pathAndInput, opts) {
|
|
|
308
334
|
const ssrOpts = useSSRQueryOptionsIfNeeded(pathAndInput, 'query', opts);
|
|
309
335
|
// request option should take priority over global
|
|
310
336
|
const shouldAbortOnUnmount = opts?.trpc?.abortOnUnmount ?? abortOnUnmount;
|
|
311
|
-
const hook = useQuery(
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
...
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
337
|
+
const hook = useQuery({
|
|
338
|
+
...ssrOpts,
|
|
339
|
+
queryKey: getArrayQueryKey(pathAndInput, 'query'),
|
|
340
|
+
queryFn: (queryFunctionContext)=>{
|
|
341
|
+
const actualOpts = {
|
|
342
|
+
...ssrOpts,
|
|
343
|
+
trpc: {
|
|
344
|
+
...ssrOpts?.trpc,
|
|
345
|
+
...shouldAbortOnUnmount ? {
|
|
346
|
+
signal: queryFunctionContext.signal
|
|
347
|
+
} : {}
|
|
348
|
+
}
|
|
349
|
+
};
|
|
350
|
+
return client.query(...getClientArgs(pathAndInput, actualOpts));
|
|
351
|
+
},
|
|
352
|
+
context: ReactQueryContext
|
|
325
353
|
});
|
|
326
354
|
hook.trpc = useHookResult({
|
|
327
355
|
path: pathAndInput[0]
|
|
@@ -334,15 +362,16 @@ function getClientArgs(pathAndInput, opts) {
|
|
|
334
362
|
const queryClient = useQueryClient({
|
|
335
363
|
context: ReactQueryContext
|
|
336
364
|
});
|
|
337
|
-
const hook = useMutation(
|
|
338
|
-
const actualPath = Array.isArray(path) ? path[0] : path;
|
|
339
|
-
return client.mutation(...getClientArgs([
|
|
340
|
-
actualPath,
|
|
341
|
-
input
|
|
342
|
-
], opts));
|
|
343
|
-
}, {
|
|
344
|
-
context: ReactQueryContext,
|
|
365
|
+
const hook = useMutation({
|
|
345
366
|
...opts,
|
|
367
|
+
mutationFn: (input)=>{
|
|
368
|
+
const actualPath = Array.isArray(path) ? path[0] : path;
|
|
369
|
+
return client.mutation(...getClientArgs([
|
|
370
|
+
actualPath,
|
|
371
|
+
input
|
|
372
|
+
], opts));
|
|
373
|
+
},
|
|
374
|
+
context: ReactQueryContext,
|
|
346
375
|
onSuccess (...args) {
|
|
347
376
|
const originalFn = ()=>opts?.onSuccess?.(...args);
|
|
348
377
|
return mutationSuccessOverride({
|
|
@@ -404,28 +433,30 @@ function getClientArgs(pathAndInput, opts) {
|
|
|
404
433
|
const ssrOpts = useSSRQueryOptionsIfNeeded(pathAndInput, 'infinite', opts);
|
|
405
434
|
// request option should take priority over global
|
|
406
435
|
const shouldAbortOnUnmount = opts?.trpc?.abortOnUnmount ?? abortOnUnmount;
|
|
407
|
-
const hook = useInfiniteQuery(
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
...
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
436
|
+
const hook = useInfiniteQuery({
|
|
437
|
+
...ssrOpts,
|
|
438
|
+
queryKey: getArrayQueryKey(pathAndInput, 'infinite'),
|
|
439
|
+
queryFn: (queryFunctionContext)=>{
|
|
440
|
+
const actualOpts = {
|
|
441
|
+
...ssrOpts,
|
|
442
|
+
trpc: {
|
|
443
|
+
...ssrOpts?.trpc,
|
|
444
|
+
...shouldAbortOnUnmount ? {
|
|
445
|
+
signal: queryFunctionContext.signal
|
|
446
|
+
} : {}
|
|
447
|
+
}
|
|
448
|
+
};
|
|
449
|
+
const actualInput = {
|
|
450
|
+
...input ?? {},
|
|
451
|
+
cursor: queryFunctionContext.pageParam
|
|
452
|
+
};
|
|
453
|
+
// FIXME as any shouldn't be needed as client should be untyped too
|
|
454
|
+
return client.query(...getClientArgs([
|
|
455
|
+
path,
|
|
456
|
+
actualInput
|
|
457
|
+
], actualOpts));
|
|
458
|
+
},
|
|
459
|
+
context: ReactQueryContext
|
|
429
460
|
});
|
|
430
461
|
hook.trpc = useHookResult({
|
|
431
462
|
path
|
package/dist/index.js
CHANGED
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var client = require('@trpc/client');
|
|
6
6
|
var shared = require('@trpc/server/shared');
|
|
7
7
|
var React = require('react');
|
|
8
|
-
var createHooksInternal = require('./createHooksInternal-
|
|
8
|
+
var createHooksInternal = require('./createHooksInternal-57a3cf21.js');
|
|
9
9
|
require('@tanstack/react-query');
|
|
10
10
|
require('./getArrayQueryKey-4bdb5cc2.js');
|
|
11
11
|
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export * from '@trpc/client';
|
|
2
2
|
import { createFlatProxy } from '@trpc/server/shared';
|
|
3
3
|
import { useMemo } from 'react';
|
|
4
|
-
import { c as createHooksInternal, a as createReactQueryUtilsProxy, b as createReactProxyDecoration } from './createHooksInternal-
|
|
4
|
+
import { c as createHooksInternal, a as createReactQueryUtilsProxy, b as createReactProxyDecoration } from './createHooksInternal-b83f2ee6.mjs';
|
|
5
5
|
import '@tanstack/react-query';
|
|
6
6
|
import './getArrayQueryKey-86134f8b.mjs';
|
|
7
7
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createHooksInternal.d.ts","sourceRoot":"","sources":["../../../src/shared/hooks/createHooksInternal.tsx"],"names":[],"mappings":"AAWA,OAAO,EAAE,mBAAmB,EAAoB,MAAM,cAAc,CAAC;AACrE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAGrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAI3D,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAE5D,OAAO,EAAE,sBAAsB,EAAuB,MAAM,UAAU,CAAC;AACvE,OAAO,EACL,YAAY,EACZ,YAAY,EAEZ,kBAAkB,EAClB,2BAA2B,EAC3B,0BAA0B,EAC1B,sBAAsB,EACtB,qBAAqB,EACrB,mBAAmB,EACnB,kBAAkB,EAClB,0BAA0B,EAC3B,MAAM,SAAS,CAAC;AAEjB;;GAEG;AACH,wBAAgB,eAAe,CAC7B,OAAO,SAAS,SAAS,EACzB,WAAW,GAAG,OAAO,EACrB,MAAM,CAAC,EAAE,sBAAsB,CAAC,OAAO,CAAC;;;;
|
|
1
|
+
{"version":3,"file":"createHooksInternal.d.ts","sourceRoot":"","sources":["../../../src/shared/hooks/createHooksInternal.tsx"],"names":[],"mappings":"AAWA,OAAO,EAAE,mBAAmB,EAAoB,MAAM,cAAc,CAAC;AACrE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAGrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAI3D,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAE5D,OAAO,EAAE,sBAAsB,EAAuB,MAAM,UAAU,CAAC;AACvE,OAAO,EACL,YAAY,EACZ,YAAY,EAEZ,kBAAkB,EAClB,2BAA2B,EAC3B,0BAA0B,EAC1B,sBAAsB,EACtB,qBAAqB,EACrB,mBAAmB,EACnB,kBAAkB,EAClB,0BAA0B,EAC3B,MAAM,SAAS,CAAC;AAEjB;;GAEG;AACH,wBAAgB,eAAe,CAC7B,OAAO,SAAS,SAAS,EACzB,WAAW,GAAG,OAAO,EACrB,MAAM,CAAC,EAAE,sBAAsB,CAAC,OAAO,CAAC;;;;6BAwNxB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,CAAC;;wBAiD1C,MAAM,GAAG,CAAC,MAAM,CAAC;oCAoCT;QAEZ,IAAI,EAAE,MAAM;QACZ,GAAG,IAAI,EAAE,OAAO,EAAE;KACnB;;qCA4Ca;QAEZ,IAAI,EAAE,MAAM;QACZ,KAAK,EAAE,OAAO,GAAG,EAAE,OAAO,CAAC;KAC5B;EAqHJ;AAED;;;GAGG;AACH,cAAc,kCAAkC,CAAC"}
|
package/dist/shared/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var createHooksInternal = require('../createHooksInternal-
|
|
5
|
+
var createHooksInternal = require('../createHooksInternal-57a3cf21.js');
|
|
6
6
|
var queryClient = require('../queryClient-358a9a75.js');
|
|
7
7
|
require('@trpc/server/shared');
|
|
8
8
|
require('../getArrayQueryKey-4bdb5cc2.js');
|
package/dist/shared/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { T as TRPCContext, f as contextProps, c as createHooksInternal, b as createReactProxyDecoration, a as createReactQueryUtilsProxy, e as createRootHooks, d as createUseQueriesProxy, g as getClientArgs } from '../createHooksInternal-
|
|
1
|
+
export { T as TRPCContext, f as contextProps, c as createHooksInternal, b as createReactProxyDecoration, a as createReactQueryUtilsProxy, e as createRootHooks, d as createUseQueriesProxy, g as getClientArgs } from '../createHooksInternal-b83f2ee6.mjs';
|
|
2
2
|
export { g as getQueryClient } from '../queryClient-4d766c0c.mjs';
|
|
3
3
|
import '@trpc/server/shared';
|
|
4
4
|
import '../getArrayQueryKey-86134f8b.mjs';
|
package/dist/ssg/index.js
CHANGED
|
@@ -18,47 +18,59 @@ var queryClient = require('../queryClient-358a9a75.js');
|
|
|
18
18
|
const queryClient$1 = queryClient.getQueryClient(opts);
|
|
19
19
|
const serialize = transformer ? ('input' in transformer ? transformer.input : transformer).serialize : (obj)=>obj;
|
|
20
20
|
const prefetchQuery = async (...pathAndInput)=>{
|
|
21
|
-
return queryClient$1.prefetchQuery(
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
21
|
+
return queryClient$1.prefetchQuery({
|
|
22
|
+
queryKey: getArrayQueryKey.getArrayQueryKey(pathAndInput, 'query'),
|
|
23
|
+
queryFn: ()=>{
|
|
24
|
+
return server.callProcedure({
|
|
25
|
+
procedures: router._def.procedures,
|
|
26
|
+
path: pathAndInput[0],
|
|
27
|
+
rawInput: pathAndInput[1],
|
|
28
|
+
ctx,
|
|
29
|
+
type: 'query'
|
|
30
|
+
});
|
|
31
|
+
}
|
|
29
32
|
});
|
|
30
33
|
};
|
|
31
34
|
const prefetchInfiniteQuery = async (...pathAndInput)=>{
|
|
32
|
-
return queryClient$1.prefetchInfiniteQuery(
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
35
|
+
return queryClient$1.prefetchInfiniteQuery({
|
|
36
|
+
queryKey: getArrayQueryKey.getArrayQueryKey(pathAndInput, 'infinite'),
|
|
37
|
+
queryFn: ()=>{
|
|
38
|
+
return server.callProcedure({
|
|
39
|
+
procedures: router._def.procedures,
|
|
40
|
+
path: pathAndInput[0],
|
|
41
|
+
rawInput: pathAndInput[1],
|
|
42
|
+
ctx,
|
|
43
|
+
type: 'query'
|
|
44
|
+
});
|
|
45
|
+
}
|
|
40
46
|
});
|
|
41
47
|
};
|
|
42
48
|
const fetchQuery = async (...pathAndInput)=>{
|
|
43
|
-
return queryClient$1.fetchQuery(
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
49
|
+
return queryClient$1.fetchQuery({
|
|
50
|
+
queryKey: getArrayQueryKey.getArrayQueryKey(pathAndInput, 'query'),
|
|
51
|
+
queryFn: ()=>{
|
|
52
|
+
return server.callProcedure({
|
|
53
|
+
procedures: router._def.procedures,
|
|
54
|
+
path: pathAndInput[0],
|
|
55
|
+
rawInput: pathAndInput[1],
|
|
56
|
+
ctx,
|
|
57
|
+
type: 'query'
|
|
58
|
+
});
|
|
59
|
+
}
|
|
51
60
|
});
|
|
52
61
|
};
|
|
53
62
|
const fetchInfiniteQuery = async (...pathAndInput)=>{
|
|
54
|
-
return queryClient$1.fetchInfiniteQuery(
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
63
|
+
return queryClient$1.fetchInfiniteQuery({
|
|
64
|
+
queryKey: getArrayQueryKey.getArrayQueryKey(pathAndInput, 'infinite'),
|
|
65
|
+
queryFn: ()=>{
|
|
66
|
+
return server.callProcedure({
|
|
67
|
+
procedures: router._def.procedures,
|
|
68
|
+
path: pathAndInput[0],
|
|
69
|
+
rawInput: pathAndInput[1],
|
|
70
|
+
ctx,
|
|
71
|
+
type: 'query'
|
|
72
|
+
});
|
|
73
|
+
}
|
|
62
74
|
});
|
|
63
75
|
};
|
|
64
76
|
function _dehydrate(opts = {
|
package/dist/ssg/index.mjs
CHANGED
|
@@ -14,47 +14,59 @@ import { g as getQueryClient } from '../queryClient-4d766c0c.mjs';
|
|
|
14
14
|
const queryClient = getQueryClient(opts);
|
|
15
15
|
const serialize = transformer ? ('input' in transformer ? transformer.input : transformer).serialize : (obj)=>obj;
|
|
16
16
|
const prefetchQuery = async (...pathAndInput)=>{
|
|
17
|
-
return queryClient.prefetchQuery(
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
17
|
+
return queryClient.prefetchQuery({
|
|
18
|
+
queryKey: getArrayQueryKey(pathAndInput, 'query'),
|
|
19
|
+
queryFn: ()=>{
|
|
20
|
+
return callProcedure({
|
|
21
|
+
procedures: router._def.procedures,
|
|
22
|
+
path: pathAndInput[0],
|
|
23
|
+
rawInput: pathAndInput[1],
|
|
24
|
+
ctx,
|
|
25
|
+
type: 'query'
|
|
26
|
+
});
|
|
27
|
+
}
|
|
25
28
|
});
|
|
26
29
|
};
|
|
27
30
|
const prefetchInfiniteQuery = async (...pathAndInput)=>{
|
|
28
|
-
return queryClient.prefetchInfiniteQuery(
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
31
|
+
return queryClient.prefetchInfiniteQuery({
|
|
32
|
+
queryKey: getArrayQueryKey(pathAndInput, 'infinite'),
|
|
33
|
+
queryFn: ()=>{
|
|
34
|
+
return callProcedure({
|
|
35
|
+
procedures: router._def.procedures,
|
|
36
|
+
path: pathAndInput[0],
|
|
37
|
+
rawInput: pathAndInput[1],
|
|
38
|
+
ctx,
|
|
39
|
+
type: 'query'
|
|
40
|
+
});
|
|
41
|
+
}
|
|
36
42
|
});
|
|
37
43
|
};
|
|
38
44
|
const fetchQuery = async (...pathAndInput)=>{
|
|
39
|
-
return queryClient.fetchQuery(
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
return queryClient.fetchQuery({
|
|
46
|
+
queryKey: getArrayQueryKey(pathAndInput, 'query'),
|
|
47
|
+
queryFn: ()=>{
|
|
48
|
+
return callProcedure({
|
|
49
|
+
procedures: router._def.procedures,
|
|
50
|
+
path: pathAndInput[0],
|
|
51
|
+
rawInput: pathAndInput[1],
|
|
52
|
+
ctx,
|
|
53
|
+
type: 'query'
|
|
54
|
+
});
|
|
55
|
+
}
|
|
47
56
|
});
|
|
48
57
|
};
|
|
49
58
|
const fetchInfiniteQuery = async (...pathAndInput)=>{
|
|
50
|
-
return queryClient.fetchInfiniteQuery(
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
59
|
+
return queryClient.fetchInfiniteQuery({
|
|
60
|
+
queryKey: getArrayQueryKey(pathAndInput, 'infinite'),
|
|
61
|
+
queryFn: ()=>{
|
|
62
|
+
return callProcedure({
|
|
63
|
+
procedures: router._def.procedures,
|
|
64
|
+
path: pathAndInput[0],
|
|
65
|
+
rawInput: pathAndInput[1],
|
|
66
|
+
ctx,
|
|
67
|
+
type: 'query'
|
|
68
|
+
});
|
|
69
|
+
}
|
|
58
70
|
});
|
|
59
71
|
};
|
|
60
72
|
function _dehydrate(opts = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trpc/react-query",
|
|
3
|
-
"version": "10.8.
|
|
3
|
+
"version": "10.8.2",
|
|
4
4
|
"description": "tRPC React lib",
|
|
5
5
|
"author": "KATT",
|
|
6
6
|
"license": "MIT",
|
|
@@ -55,15 +55,15 @@
|
|
|
55
55
|
},
|
|
56
56
|
"peerDependencies": {
|
|
57
57
|
"@tanstack/react-query": "^4.3.8",
|
|
58
|
-
"@trpc/client": "10.8.
|
|
59
|
-
"@trpc/server": "10.8.
|
|
58
|
+
"@trpc/client": "10.8.2",
|
|
59
|
+
"@trpc/server": "10.8.2",
|
|
60
60
|
"react": ">=16.8.0",
|
|
61
61
|
"react-dom": ">=16.8.0"
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
64
64
|
"@tanstack/react-query": "^4.3.8",
|
|
65
|
-
"@trpc/client": "10.8.
|
|
66
|
-
"@trpc/server": "10.8.
|
|
65
|
+
"@trpc/client": "10.8.2",
|
|
66
|
+
"@trpc/server": "10.8.2",
|
|
67
67
|
"@types/express": "^4.17.12",
|
|
68
68
|
"@types/node": "^18.7.20",
|
|
69
69
|
"eslint": "^8.30.0",
|
|
@@ -78,5 +78,5 @@
|
|
|
78
78
|
"publishConfig": {
|
|
79
79
|
"access": "public"
|
|
80
80
|
},
|
|
81
|
-
"gitHead": "
|
|
81
|
+
"gitHead": "2be6d09a08fc3a32b86286271ab8b4881b6bc98b"
|
|
82
82
|
}
|
|
@@ -78,96 +78,103 @@ export function createRootHooks<
|
|
|
78
78
|
ssrState,
|
|
79
79
|
fetchQuery: useCallback(
|
|
80
80
|
(pathAndInput, opts) => {
|
|
81
|
-
return queryClient.fetchQuery(
|
|
82
|
-
|
|
83
|
-
()
|
|
81
|
+
return queryClient.fetchQuery({
|
|
82
|
+
...opts,
|
|
83
|
+
queryKey: getArrayQueryKey(pathAndInput, 'query'),
|
|
84
|
+
queryFn: () =>
|
|
84
85
|
(client as any).query(...getClientArgs(pathAndInput, opts)),
|
|
85
|
-
|
|
86
|
-
);
|
|
86
|
+
});
|
|
87
87
|
},
|
|
88
88
|
[client, queryClient],
|
|
89
89
|
),
|
|
90
90
|
fetchInfiniteQuery: useCallback(
|
|
91
91
|
(pathAndInput, opts) => {
|
|
92
|
-
return queryClient.fetchInfiniteQuery(
|
|
93
|
-
|
|
94
|
-
(
|
|
92
|
+
return queryClient.fetchInfiniteQuery({
|
|
93
|
+
...opts,
|
|
94
|
+
queryKey: getArrayQueryKey(pathAndInput, 'infinite'),
|
|
95
|
+
queryFn: ({ pageParam }) => {
|
|
95
96
|
const [path, input] = pathAndInput;
|
|
96
|
-
const actualInput = { ...
|
|
97
|
+
const actualInput = { ...input, cursor: pageParam };
|
|
97
98
|
return (client as any).query(
|
|
98
99
|
...getClientArgs([path, actualInput], opts),
|
|
99
100
|
);
|
|
100
101
|
},
|
|
101
|
-
|
|
102
|
-
);
|
|
102
|
+
});
|
|
103
103
|
},
|
|
104
104
|
[client, queryClient],
|
|
105
105
|
),
|
|
106
106
|
prefetchQuery: useCallback(
|
|
107
107
|
(pathAndInput, opts) => {
|
|
108
|
-
return queryClient.prefetchQuery(
|
|
109
|
-
|
|
110
|
-
()
|
|
108
|
+
return queryClient.prefetchQuery({
|
|
109
|
+
...opts,
|
|
110
|
+
queryKey: getArrayQueryKey(pathAndInput, 'query'),
|
|
111
|
+
queryFn: () =>
|
|
111
112
|
(client as any).query(...getClientArgs(pathAndInput, opts)),
|
|
112
|
-
|
|
113
|
-
);
|
|
113
|
+
});
|
|
114
114
|
},
|
|
115
115
|
[client, queryClient],
|
|
116
116
|
),
|
|
117
117
|
prefetchInfiniteQuery: useCallback(
|
|
118
118
|
(pathAndInput, opts) => {
|
|
119
|
-
return queryClient.prefetchInfiniteQuery(
|
|
120
|
-
|
|
121
|
-
(
|
|
119
|
+
return queryClient.prefetchInfiniteQuery({
|
|
120
|
+
...opts,
|
|
121
|
+
queryKey: getArrayQueryKey(pathAndInput, 'infinite'),
|
|
122
|
+
queryFn: ({ pageParam }) => {
|
|
122
123
|
const [path, input] = pathAndInput;
|
|
123
|
-
const actualInput = { ...
|
|
124
|
+
const actualInput = { ...input, cursor: pageParam };
|
|
124
125
|
return (client as any).query(
|
|
125
126
|
...getClientArgs([path, actualInput], opts),
|
|
126
127
|
);
|
|
127
128
|
},
|
|
128
|
-
|
|
129
|
-
);
|
|
129
|
+
});
|
|
130
130
|
},
|
|
131
131
|
[client, queryClient],
|
|
132
132
|
),
|
|
133
133
|
invalidateQueries: useCallback(
|
|
134
|
-
(
|
|
135
|
-
const [queryKey, ...rest] = args;
|
|
136
|
-
|
|
134
|
+
(queryKey, filters, options) => {
|
|
137
135
|
return queryClient.invalidateQueries(
|
|
138
|
-
|
|
139
|
-
|
|
136
|
+
{
|
|
137
|
+
...filters,
|
|
138
|
+
queryKey: getArrayQueryKey(queryKey as any, 'any'),
|
|
139
|
+
},
|
|
140
|
+
options,
|
|
140
141
|
);
|
|
141
142
|
},
|
|
142
143
|
[queryClient],
|
|
143
144
|
),
|
|
144
145
|
resetQueries: useCallback(
|
|
145
146
|
(...args: any[]) => {
|
|
146
|
-
const [queryKey,
|
|
147
|
+
const [queryKey, filters, options] = args;
|
|
147
148
|
|
|
148
149
|
return queryClient.resetQueries(
|
|
149
|
-
|
|
150
|
-
|
|
150
|
+
{
|
|
151
|
+
...filters,
|
|
152
|
+
queryKey: getArrayQueryKey(queryKey, 'any'),
|
|
153
|
+
},
|
|
154
|
+
options,
|
|
151
155
|
);
|
|
152
156
|
},
|
|
153
157
|
[queryClient],
|
|
154
158
|
),
|
|
155
159
|
refetchQueries: useCallback(
|
|
156
160
|
(...args: any[]) => {
|
|
157
|
-
const [queryKey,
|
|
161
|
+
const [queryKey, filters, options] = args;
|
|
158
162
|
|
|
159
163
|
return queryClient.refetchQueries(
|
|
160
|
-
|
|
161
|
-
|
|
164
|
+
{
|
|
165
|
+
...filters,
|
|
166
|
+
queryKey: getArrayQueryKey(queryKey, 'any'),
|
|
167
|
+
},
|
|
168
|
+
options,
|
|
162
169
|
);
|
|
163
170
|
},
|
|
164
171
|
[queryClient],
|
|
165
172
|
),
|
|
166
173
|
cancelQuery: useCallback(
|
|
167
174
|
(pathAndInput) => {
|
|
168
|
-
return queryClient.cancelQueries(
|
|
169
|
-
getArrayQueryKey(pathAndInput, 'any'),
|
|
170
|
-
);
|
|
175
|
+
return queryClient.cancelQueries({
|
|
176
|
+
queryKey: getArrayQueryKey(pathAndInput, 'any'),
|
|
177
|
+
});
|
|
171
178
|
},
|
|
172
179
|
[queryClient],
|
|
173
180
|
),
|
|
@@ -269,9 +276,10 @@ export function createRootHooks<
|
|
|
269
276
|
// request option should take priority over global
|
|
270
277
|
const shouldAbortOnUnmount = opts?.trpc?.abortOnUnmount ?? abortOnUnmount;
|
|
271
278
|
|
|
272
|
-
const hook = __useQuery(
|
|
273
|
-
|
|
274
|
-
(
|
|
279
|
+
const hook = __useQuery({
|
|
280
|
+
...ssrOpts,
|
|
281
|
+
queryKey: getArrayQueryKey(pathAndInput, 'query') as any,
|
|
282
|
+
queryFn: (queryFunctionContext) => {
|
|
275
283
|
const actualOpts = {
|
|
276
284
|
...ssrOpts,
|
|
277
285
|
trpc: {
|
|
@@ -286,8 +294,9 @@ export function createRootHooks<
|
|
|
286
294
|
...getClientArgs(pathAndInput, actualOpts),
|
|
287
295
|
);
|
|
288
296
|
},
|
|
289
|
-
|
|
290
|
-
) as UseTRPCQueryResult<unknown, TError>;
|
|
297
|
+
context: ReactQueryContext,
|
|
298
|
+
}) as UseTRPCQueryResult<unknown, TError>;
|
|
299
|
+
|
|
291
300
|
hook.trpc = useHookResult({
|
|
292
301
|
path: pathAndInput[0],
|
|
293
302
|
});
|
|
@@ -303,28 +312,26 @@ export function createRootHooks<
|
|
|
303
312
|
const { client } = useContext();
|
|
304
313
|
const queryClient = useQueryClient({ context: ReactQueryContext });
|
|
305
314
|
|
|
306
|
-
const hook = __useMutation(
|
|
307
|
-
|
|
315
|
+
const hook = __useMutation({
|
|
316
|
+
...opts,
|
|
317
|
+
mutationFn: (input) => {
|
|
308
318
|
const actualPath = Array.isArray(path) ? path[0] : path;
|
|
309
319
|
|
|
310
320
|
return (client.mutation as any)(
|
|
311
321
|
...getClientArgs([actualPath, input], opts),
|
|
312
322
|
);
|
|
313
323
|
},
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
...
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
meta: opts?.meta ?? {},
|
|
324
|
-
});
|
|
325
|
-
},
|
|
324
|
+
context: ReactQueryContext,
|
|
325
|
+
onSuccess(...args) {
|
|
326
|
+
const originalFn = () => opts?.onSuccess?.(...args);
|
|
327
|
+
|
|
328
|
+
return mutationSuccessOverride({
|
|
329
|
+
originalFn,
|
|
330
|
+
queryClient,
|
|
331
|
+
meta: opts?.meta ?? {},
|
|
332
|
+
});
|
|
326
333
|
},
|
|
327
|
-
) as UseTRPCMutationResult<unknown, TError, unknown, unknown>;
|
|
334
|
+
}) as UseTRPCMutationResult<unknown, TError, unknown, unknown>;
|
|
328
335
|
|
|
329
336
|
hook.trpc = useHookResult({
|
|
330
337
|
path: Array.isArray(path) ? path[0] : path,
|
|
@@ -416,9 +423,10 @@ export function createRootHooks<
|
|
|
416
423
|
// request option should take priority over global
|
|
417
424
|
const shouldAbortOnUnmount = opts?.trpc?.abortOnUnmount ?? abortOnUnmount;
|
|
418
425
|
|
|
419
|
-
const hook = __useInfiniteQuery(
|
|
420
|
-
|
|
421
|
-
(
|
|
426
|
+
const hook = __useInfiniteQuery({
|
|
427
|
+
...ssrOpts,
|
|
428
|
+
queryKey: getArrayQueryKey(pathAndInput, 'infinite') as any,
|
|
429
|
+
queryFn: (queryFunctionContext) => {
|
|
422
430
|
const actualOpts = {
|
|
423
431
|
...ssrOpts,
|
|
424
432
|
trpc: {
|
|
@@ -439,8 +447,8 @@ export function createRootHooks<
|
|
|
439
447
|
...getClientArgs([path, actualInput], actualOpts),
|
|
440
448
|
);
|
|
441
449
|
},
|
|
442
|
-
|
|
443
|
-
) as UseTRPCInfiniteQueryResult<unknown, TError>;
|
|
450
|
+
context: ReactQueryContext,
|
|
451
|
+
}) as UseTRPCInfiniteQueryResult<unknown, TError>;
|
|
444
452
|
|
|
445
453
|
hook.trpc = useHookResult({
|
|
446
454
|
path,
|
package/src/ssg/ssg.ts
CHANGED
|
@@ -44,9 +44,9 @@ export function createSSGHelpers<TRouter extends AnyRouter>(
|
|
|
44
44
|
>(
|
|
45
45
|
...pathAndInput: [path: TPath, ...args: inferHandlerInput<TProcedure>]
|
|
46
46
|
) => {
|
|
47
|
-
return queryClient.prefetchQuery(
|
|
48
|
-
getArrayQueryKey(pathAndInput, 'query'),
|
|
49
|
-
() => {
|
|
47
|
+
return queryClient.prefetchQuery({
|
|
48
|
+
queryKey: getArrayQueryKey(pathAndInput, 'query'),
|
|
49
|
+
queryFn: () => {
|
|
50
50
|
return callProcedure({
|
|
51
51
|
procedures: router._def.procedures,
|
|
52
52
|
path: pathAndInput[0],
|
|
@@ -55,7 +55,7 @@ export function createSSGHelpers<TRouter extends AnyRouter>(
|
|
|
55
55
|
type: 'query',
|
|
56
56
|
});
|
|
57
57
|
},
|
|
58
|
-
);
|
|
58
|
+
});
|
|
59
59
|
};
|
|
60
60
|
|
|
61
61
|
const prefetchInfiniteQuery = async <
|
|
@@ -64,9 +64,9 @@ export function createSSGHelpers<TRouter extends AnyRouter>(
|
|
|
64
64
|
>(
|
|
65
65
|
...pathAndInput: [path: TPath, ...args: inferHandlerInput<TProcedure>]
|
|
66
66
|
) => {
|
|
67
|
-
return queryClient.prefetchInfiniteQuery(
|
|
68
|
-
getArrayQueryKey(pathAndInput, 'infinite'),
|
|
69
|
-
() => {
|
|
67
|
+
return queryClient.prefetchInfiniteQuery({
|
|
68
|
+
queryKey: getArrayQueryKey(pathAndInput, 'infinite'),
|
|
69
|
+
queryFn: () => {
|
|
70
70
|
return callProcedure({
|
|
71
71
|
procedures: router._def.procedures,
|
|
72
72
|
path: pathAndInput[0],
|
|
@@ -75,7 +75,7 @@ export function createSSGHelpers<TRouter extends AnyRouter>(
|
|
|
75
75
|
type: 'query',
|
|
76
76
|
});
|
|
77
77
|
},
|
|
78
|
-
);
|
|
78
|
+
});
|
|
79
79
|
};
|
|
80
80
|
|
|
81
81
|
const fetchQuery = async <
|
|
@@ -85,9 +85,9 @@ export function createSSGHelpers<TRouter extends AnyRouter>(
|
|
|
85
85
|
>(
|
|
86
86
|
...pathAndInput: [path: TPath, ...args: inferHandlerInput<TProcedure>]
|
|
87
87
|
): Promise<TOutput> => {
|
|
88
|
-
return queryClient.fetchQuery(
|
|
89
|
-
getArrayQueryKey(pathAndInput, 'query'),
|
|
90
|
-
() => {
|
|
88
|
+
return queryClient.fetchQuery({
|
|
89
|
+
queryKey: getArrayQueryKey(pathAndInput, 'query'),
|
|
90
|
+
queryFn: () => {
|
|
91
91
|
return callProcedure({
|
|
92
92
|
procedures: router._def.procedures,
|
|
93
93
|
path: pathAndInput[0],
|
|
@@ -96,7 +96,7 @@ export function createSSGHelpers<TRouter extends AnyRouter>(
|
|
|
96
96
|
type: 'query',
|
|
97
97
|
});
|
|
98
98
|
},
|
|
99
|
-
);
|
|
99
|
+
});
|
|
100
100
|
};
|
|
101
101
|
|
|
102
102
|
const fetchInfiniteQuery = async <
|
|
@@ -106,9 +106,9 @@ export function createSSGHelpers<TRouter extends AnyRouter>(
|
|
|
106
106
|
>(
|
|
107
107
|
...pathAndInput: [path: TPath, ...args: inferHandlerInput<TProcedure>]
|
|
108
108
|
): Promise<InfiniteData<TOutput>> => {
|
|
109
|
-
return queryClient.fetchInfiniteQuery(
|
|
110
|
-
getArrayQueryKey(pathAndInput, 'infinite'),
|
|
111
|
-
() => {
|
|
109
|
+
return queryClient.fetchInfiniteQuery({
|
|
110
|
+
queryKey: getArrayQueryKey(pathAndInput, 'infinite'),
|
|
111
|
+
queryFn: () => {
|
|
112
112
|
return callProcedure({
|
|
113
113
|
procedures: router._def.procedures,
|
|
114
114
|
path: pathAndInput[0],
|
|
@@ -117,7 +117,7 @@ export function createSSGHelpers<TRouter extends AnyRouter>(
|
|
|
117
117
|
type: 'query',
|
|
118
118
|
});
|
|
119
119
|
},
|
|
120
|
-
);
|
|
120
|
+
});
|
|
121
121
|
};
|
|
122
122
|
|
|
123
123
|
function _dehydrate(
|