import { GET_PRODUCT_REVIEWS } from "@/graphql"; import { cachedProductRequest } from "./useCache"; export async function getProductReviews(productId: string) { try { const variables = { product_id: Number(productId), first: 10 }; const {data:response} = await cachedProductRequest( // productId, GET_PRODUCT_REVIEWS, variables ); return response?.productReviews?.edges || []; } catch (error) { if (error instanceof Error) { console.error("Error fetching product reviews:", { message: error.message, productId, graphQLErrors: (error as unknown as Record) .graphQLErrors, }); } return []; } }