From 19cf9972d6bcf2d292dfe8da31f7d80a3064705e Mon Sep 17 00:00:00 2001 From: Anshuman Pandey <54475686+pandeymangg@users.noreply.github.com> Date: Fri, 26 Apr 2024 14:08:44 +0530 Subject: [PATCH] fix: product cache revalidation on product create (#2538) --- packages/lib/product/service.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/lib/product/service.ts b/packages/lib/product/service.ts index 02f26974fe..b719f33b63 100644 --- a/packages/lib/product/service.ts +++ b/packages/lib/product/service.ts @@ -273,6 +273,11 @@ export const createProduct = async ( select: selectProduct, }); + productCache.revalidate({ + id: product.id, + teamId: product.teamId, + }); + const devEnvironment = await createEnvironment(product.id, { type: "development", }); @@ -281,9 +286,11 @@ export const createProduct = async ( type: "production", }); - return await updateProduct(product.id, { + const updatedProduct = await updateProduct(product.id, { environments: [devEnvironment, prodEnvironment], }); + + return updatedProduct; } catch (error) { if (error instanceof Prisma.PrismaClientKnownRequestError) { throw new DatabaseError(error.message);