T
tRPC

Where can I add a query key?

Where can I add a query key?

AAli3/15/2023
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,
});
Nnlucas3/15/2023
Complaining how?
AAli3/15/2023
@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'.
Nnlucas3/15/2023
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

Looking for more? Join the community!

T
tRPC

Where can I add a query key?

Join Server