Skip to content

Commit be64d3d

Browse files
authored
Update createUtils proxy to include path in context (#54)
* fix: update `createUtils` proxy to include path in context * bump version
1 parent 297e18a commit be64d3d

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

@lib/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "trpc-svelte-query-adapter",
3-
"version": "2.3.12",
3+
"version": "2.3.13",
44
"description": "A simple adapter to use `@tanstack/svelte-query` with trpc, similar to `@trpc/react-query`.",
55
"keywords": [
66
"trpc",

@lib/src/index.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ type GetQueryKey<TInput = undefined> = [TInput] extends [undefined | void]
258258
* Method to extract the query key for a procedure
259259
* @param type - defaults to `any`
260260
*/
261-
[Procedure.queryKey]: (input: TInput, type?: QueryType) => TRPCQueryKey;
261+
[Procedure.queryKey]: (input?: TInput, type?: QueryType) => TRPCQueryKey;
262262
} & {};
263263

264264
function getClientArgs<TOptions>(
@@ -942,6 +942,7 @@ const utilProcedures: Record<
942942
},
943943
[Util.Query.invalidate]: ({ path, queryClient, key }) => {
944944
return (input?: any, filters?: any, options?: any) => {
945+
console.log(path, input, getQueryType(key as any));
945946
const queryKey = getQueryKeyInternal(
946947
path,
947948
input,
@@ -1087,7 +1088,9 @@ function createUtilsProxy(ctx: WrapperContext) {
10871088
if (key === Util.Query.client) return ctx.baseClient;
10881089

10891090
if (hasOwn(utilProcedures, key)) {
1090-
return utilProcedures[key](Object.assign(ctx, { key }));
1091+
return utilProcedures[key](
1092+
Object.assign(ctx, { key, path: this.path })
1093+
);
10911094
}
10921095

10931096
return this.nest(() => {});
@@ -1132,7 +1135,7 @@ const procedures: Record<
11321135
(ctx: WrapperContext) => any
11331136
> = {
11341137
[Procedure.queryKey]: ({ path }) => {
1135-
return (input: any, opts?: any) => getQueryKeyInternal(path, input, opts);
1138+
return (input?: any, opts?: any) => getQueryKeyInternal(path, input, opts);
11361139
},
11371140
[Procedure.query]: ({ path, client, abortOnUnmount, queryClient }) => {
11381141
return (input: any, opts?: any) => {

0 commit comments

Comments
 (0)