Ayush GoyalA
tRPC3y ago
4 replies
Ayush Goyal

opts object passed to mutation , i can not understand where it came from

export const authorizedProcedure = publicProcedure
  .input(z.object({ townName: z.string() }))
  .use((opts) => {
    if (opts.input.townName !== 'Pucklechurch') {
      throw new TRPCError({
        code: 'FORBIDDEN',
        message: "We don't take kindly to out-of-town folk",
      });
    }
 
    return opts.next();
  });
 
export const appRouter = t.router({
  hello: authorizedProcedure.query(() => {
    return {
      message: 'hello world',
    };
  }),
  goodbye: authorizedProcedure.mutation(async (opts) => {
    await opts.ctx.signGuestBook();
 
    return {
      message: 'goodbye!',
    };
  }),
});


here in goodbye route , where does the opts object come from , in authorized proccesor middleware , i get it otps come from the input but in goodbye i am not able to understand where opts come from , maybe

  return opts.next();


passes it to the goodbye route
Was this page helpful?