Next.js Discord

Discord Forum

Not Updating data while fetching(Apollo-client)App Router

Unanswered
hariom mahato posted this in #help-forum
Open in Discord
Avatar
hariom mahatoOP
"use client"
const onSubmit: SubmitHandler<CreateProductInput> = async (values) => {
try {
await createProduct({
variables: {
data: {
name: values.name,
category: values.category,
description: values.description,
discountPrice: Number(values.discountPrice),
images: values.images,
originalPrice: Number(values.originalPrice),
stock: Number(values.stock),
},
},
onCompleted: () => {
toast.success("SuccessFully Created Product");
router.push("/seller/dashboard/all-products");
resetServerResponse();
},
onError: (error) => {
toast.error(error?.message);
},
});
} catch (error) {
console.error("Failed to register:", error);
resetServerResponse();
}
};

WHEN CREATING NEW PRODUCT I AM DOING ROUTER.PUSH THEN IN THAT PAGEimport AllProductSeller from "@/components/Product/AllProductSeller";
import { GetAllProductsDocument, Product } from "@/graphql/generated/schema";
import { getClient } from "@/lib/client";
import React from "react";
// export const revalidate=5
export const dynamic = "force-dynamic";
const SellerAllProductClient = async () => {
const { data } = await getClient().query<{ getAllProducts: Product[] }>({
query: GetAllProductsDocument,
context: {
fetchOptions: {
next: { revalidate: 5 },
},
},
});

console.log(data?.getAllProducts?.length);
return (
#Unknown Channel
<AllProductSeller products={data?.getAllProducts} />
</>
);
};

export default SellerAllProductClient;
I AM NOT GETTING LATEST DATA AND NOT FETCHING LATEST WHY

0 Replies