Krishna
Krishna
TtRPC
Created by Krishna on 11/7/2023 in #❓-help
empty `input` object when using mutation
When using useQuery I have no issues even with input but when using useMutation. The backend is receiving an empty input. What could be the reason? stack is nodejs + express + reactjs + yarn Frontend code
const devCompanyMutation = trpc.devCompany.create.useMutation();

const onSubmit = (latestDoc: T_Insert_DevCompany) => {
console.log({latestDoc});
devCompanyMutation.mutate(latestDoc);
};
const devCompanyMutation = trpc.devCompany.create.useMutation();

const onSubmit = (latestDoc: T_Insert_DevCompany) => {
console.log({latestDoc});
devCompanyMutation.mutate(latestDoc);
};
Backend code
export const devCompanyRouter = router({
create: publicProcedure
.input(z.object({
name: z.string().nullish()
}).nullish())
.mutation(({ input }) => {
console.log({input})
return input;
})
})
export const devCompanyRouter = router({
create: publicProcedure
.input(z.object({
name: z.string().nullish()
}).nullish())
.mutation(({ input }) => {
console.log({input})
return input;
})
})
4 replies
TtRPC
Created by Krishna on 11/5/2023 in #❓-help
The inferred type of 'trpc' cannot be named without a reference. A type annotation is necessary.
No description
3 replies