Ali
Ali2y ago

Where can I add a query key?

I tried to follow as in useQuery from Tanstack, but Typescript started complaining
api.prompts.tags.useQuery(undefined, {
cacheTime: 60 * 60 * 40,
});
api.prompts.tags.useQuery(undefined, {
cacheTime: 60 * 60 * 40,
});
3 Replies
Nick
Nick2y ago
Complaining how?
Ali
AliOP2y ago
@Nick Lucas no overload... I want use query keys only for caching purposes
No overload matches this call.
Overload 1 of 2, '(input: void | undefined, opts: DefinedUseTRPCQueryOptions<"prompts.tags", void | undefined, string[], string[], TRPCClientErrorLike<BuildProcedure<"query", { _config: RootConfig<{ ctx: { session: Session | null; }; meta: object; errorShape: DefaultErrorShape; transformer: { ...; }; }>; ... 5 more ...; _meta: object; }, string[]>>>): DefinedUseTRPCQueryResult<...>', gave the following error.
Argument of type 'never[] | string[]' is not assignable to parameter of type 'void | undefined'.
Type 'never[]' is not assignable to type 'void'.
Overload 2 of 2, '(input: void | undefined, opts?: UseTRPCQueryOptions<"prompts.tags", void | undefined, string[], string[], TRPCClientErrorLike<BuildProcedure<"query", { _config: RootConfig<{ ctx: { session: Session | null; }; meta: object; errorShape: DefaultErrorShape; transformer: { ...; }; }>; ... 5 more ...; _meta: object; }, string[]>>> | undefined): UseTRPCQueryResult<...>', gave the following error.
Argument of type 'never[] | string[]' is not assignable to parameter of type 'void | undefined'.
No overload matches this call.
Overload 1 of 2, '(input: void | undefined, opts: DefinedUseTRPCQueryOptions<"prompts.tags", void | undefined, string[], string[], TRPCClientErrorLike<BuildProcedure<"query", { _config: RootConfig<{ ctx: { session: Session | null; }; meta: object; errorShape: DefaultErrorShape; transformer: { ...; }; }>; ... 5 more ...; _meta: object; }, string[]>>>): DefinedUseTRPCQueryResult<...>', gave the following error.
Argument of type 'never[] | string[]' is not assignable to parameter of type 'void | undefined'.
Type 'never[]' is not assignable to type 'void'.
Overload 2 of 2, '(input: void | undefined, opts?: UseTRPCQueryOptions<"prompts.tags", void | undefined, string[], string[], TRPCClientErrorLike<BuildProcedure<"query", { _config: RootConfig<{ ctx: { session: Session | null; }; meta: object; errorShape: DefaultErrorShape; transformer: { ...; }; }>; ... 5 more ...; _meta: object; }, string[]>>> | undefined): UseTRPCQueryResult<...>', gave the following error.
Argument of type 'never[] | string[]' is not assignable to parameter of type 'void | undefined'.
Nick
Nick2y ago
So I’m not what you’re saying you’re doing tracks with the code sample you’re giving, you’re not actually trying to set query keys there? Query keys are managed by tRPC so you don’t need to worry about them, caching works out of the box

Did you find this page helpful?