codecret | Software Engineer
codecret | Software Engineer
TtRPC
Created by codecret | Software Engineer on 2/15/2025 in #❓-help
correct way to handle errors run time errors
No description
7 replies
TtRPC
Created by codecret | Software Engineer on 2/13/2025 in #❓-help
invalidate query
whenever i add a user my user list is not updating
const mutation = trpc.user.addUser.useMutation();

async function onSubmit(values: z.infer<typeof formSchema>) {
await mutation.mutateAsync(values);
router.push("/admin/all-employees");
}
const mutation = trpc.user.addUser.useMutation();

async function onSubmit(values: z.infer<typeof formSchema>) {
await mutation.mutateAsync(values);
router.push("/admin/all-employees");
}
does not get updated
const { data: users, isLoading } = trpc.user.getUsers.useQuery(undefined, {
refetchOnMount: false,
refetchOnReconnect: false,
});
const { data: users, isLoading } = trpc.user.getUsers.useQuery(undefined, {
refetchOnMount: false,
refetchOnReconnect: false,
});
what i have tried :
const mutation = trpc.user.addUser.useMutation(["addUser"]);
const mutation = trpc.user.addUser.useMutation(["addUser"]);
searched for invalidate query but couldn't know how to setup a mutation key and invalidate it caused an error
Type 'string[]' has no properties in common with type 'UseTRPCMutationOptions<{ name: string; email: string; username: string; password: string; role: string; }, TRPCClientErrorLike<{ input: { name: string; email: string; username: string; password: string; role: string; }; output: { user: { name: string; ... 9 more ...; | undefined;...'.ts(2559)
Type 'string[]' has no properties in common with type 'UseTRPCMutationOptions<{ name: string; email: string; username: string; password: string; role: string; }, TRPCClientErrorLike<{ input: { name: string; email: string; username: string; password: string; role: string; }; output: { user: { name: string; ... 9 more ...; | undefined;...'.ts(2559)
16 replies