Skip to content

Commit

Permalink
Provide just the query key as input to getQueryData instead of filt…
Browse files Browse the repository at this point in the history
…ers (#31)

* fix: provide proper input for `getQueryData`

* bump version
  • Loading branch information
vishalbalaji authored Mar 2, 2024
1 parent 839bd76 commit 31af9f1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 13 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "trpc-svelte-query-adapter",
"version": "2.2.4",
"version": "2.2.5",
"description": "A simple adapter to use `@tanstack/svelte-query` with trpc, similar to `@trpc/react-query`.",
"keywords": [
"trpc",
Expand Down
18 changes: 6 additions & 12 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,12 @@ type UtilsProcedures<TInput = undefined, TOutput = undefined, TError = undefined
/**
* @link https://tanstack.com/query/v4/docs/reference/QueryClient#queryclientgetquerydata
*/
[UtilsProcedureNames.getData](input?: TInput, filters?: QueryFilters): TOutput | undefined
[UtilsProcedureNames.getData](input?: TInput): TOutput | undefined

/**
* @link https://tanstack.com/query/v4/docs/reference/QueryClient#queryclientgetquerydata
*/
[UtilsProcedureNames.getInfiniteData](input?: TInput, filters?: QueryFilters): InfiniteData<TOutput> | undefined
[UtilsProcedureNames.getInfiniteData](input?: TInput): InfiniteData<TOutput> | undefined
}

type AddUtilsPropTypes<TClient, TError> = {
Expand Down Expand Up @@ -387,19 +387,13 @@ const utilsProcedures: Record<PropertyKey,
};
},
[UtilsProcedureNames.getData]: ({ queryClient, path }) => {
return (input?: any, filters?: any) => {
return queryClient.getQueryData({
...filters,
queryKey: getArrayQueryKey(path, input, 'query'),
});
return (input?: any) => {
return queryClient.getQueryData(getArrayQueryKey(path, input, 'query'));
};
},
[UtilsProcedureNames.getInfiniteData]: ({ queryClient, path }) => {
return (input?: any, filters?: any) => {
return queryClient.getQueryData({
queryKey: getArrayQueryKey(path, input, 'infinite'),
...filters,
});
return (input?: any) => {
return queryClient.getQueryData(getArrayQueryKey(path, input, 'infinite'));
};
},
};
Expand Down

0 comments on commit 31af9f1

Please sign in to comment.