jackmcbride_98
jackmcbride_98
TTCTheo's Typesafe Cult
Created by jackmcbride_98 on 10/4/2023 in #questions
How do I revalidatePath from a trpc router?
TRPCClientError: Invariant: static generation store missing in revalidateTag / I'm getting this error when I try to call revalidatePath from my trpc router.
import { z } from "zod";
import {
createTRPCRouter,
publicProcedure,
protectedProcedure,
} from "@/server/api/trpc";
import { formSchema } from "@/pages/admin";
import { revalidatePath } from "next/cache";

export const gigsRouter = createTRPCRouter({
getAll: publicProcedure.query(({ ctx }) => {
return ctx.prisma.gigs.findMany();
}),

create: protectedProcedure.input(formSchema).mutation(({ ctx, input }) => {
revalidatePath("/");

return ctx.prisma.gigs.create({
data: {
...input,
date: new Date(input.date),
},
});
}),

delete: protectedProcedure
.input(z.object({ id: z.string() }))
.mutation(({ ctx, input }) => {
revalidatePath("/");

return ctx.prisma.gigs.delete({ where: { id: input.id } });
}),
});
import { z } from "zod";
import {
createTRPCRouter,
publicProcedure,
protectedProcedure,
} from "@/server/api/trpc";
import { formSchema } from "@/pages/admin";
import { revalidatePath } from "next/cache";

export const gigsRouter = createTRPCRouter({
getAll: publicProcedure.query(({ ctx }) => {
return ctx.prisma.gigs.findMany();
}),

create: protectedProcedure.input(formSchema).mutation(({ ctx, input }) => {
revalidatePath("/");

return ctx.prisma.gigs.create({
data: {
...input,
date: new Date(input.date),
},
});
}),

delete: protectedProcedure
.input(z.object({ id: z.string() }))
.mutation(({ ctx, input }) => {
revalidatePath("/");

return ctx.prisma.gigs.delete({ where: { id: input.id } });
}),
});
11 replies
TTCTheo's Typesafe Cult
Created by jackmcbride_98 on 10/4/2023 in #questions
What to do about Date not serializable when calling getServerSideProps?
https://clips.twitch.tv/DrabPatientKathyArsonNoSexy-O_B1C2XYw_9SFEg2 Do I have to use multiple types or is there a way around this?
6 replies