OutisO
tRPC4y ago
38 replies
Outis

Mutation type issue

I'm trying to mutate something like this with tRPC and Prisma
const updateColumn = trpc.project.update.useMutation();
updateColumn.mutate({ colId: list.id, cards: list.cards })


list.id is just a string but list.cards has a type of Card[] which I'm importing from a file Prisma auto-generated from my schema

Then on my backend
update: protectedProcedure
    .input(
      z.object({
        colId: z.string(),
        cards: //what do I put here?
      })
    )
    .mutation(async ({ input, ctx }) => {
      const result = await ctx.prisma.column.update({
        where: {
          id: input.colId,
        },
        data: {
          cards: input.cards, //type error
        },
      });

      console.log(result, "?dbresult");
    })


I tried putting something like z.array(z.object({})) but obviously that doesn't work and it shows this error
unknown.png
Was this page helpful?