2

I'm having a bit of trouble with my mutation code in tRPC v10.

The getCookie query below is working fine, but the setCookie mutation is not coming through to the client side TS, or executing successfully - any idea why?

export const appRouter = router({
  getCookie: publicProcedure
    .input(z.string())
    .query(async ({ input }) => {
      return ""
    }),

  setCookie: publicProcedure
    .input(z.string())
    .mutation(async ({ input }) => {
      console.log(" set cookie: ", input);
    }),
});

export type AppRouter = typeof appRouter;

The client code (running in getServersideProps and jest) is as follows:

  const ssg = createProxySSGHelpers({
    router: appRouter,
    ctx: await createContext(),
    transformer: superjson,
  });

 const cookie = await ssg.getCookie.fetch("test"); // ✅✅✅ Works

 const result = await ssg.setCookie.fetch(cookie); // ❗❗❗ fails!!!

The result is failing - the setCookie function is not on the ssg object though

TRPCError: No "query"-procedure on path "setChesskidCookie"

fotoflo
  • 821
  • 1
  • 9
  • 21

0 Answers0