@@ -211,7 +211,7 @@ export const getProduct = cache(async (entityId: number, customerAccessToken?: s
211211 return data . site ;
212212} ) ;
213213
214- const StreamableProductVariantBySkuQuery = graphql ( `
214+ const StreamableProductVariantInventoryBySkuQuery = graphql ( `
215215 query ProductVariantBySkuQuery($productId: Int!, $sku: String!) {
216216 site {
217217 product(entityId: $productId) {
@@ -247,15 +247,15 @@ const StreamableProductVariantBySkuQuery = graphql(`
247247 }
248248` ) ;
249249
250- type VariantVariables = VariablesOf < typeof StreamableProductVariantBySkuQuery > ;
250+ type VariantInventoryVariables = VariablesOf < typeof StreamableProductVariantInventoryBySkuQuery > ;
251251
252- export const getStreamableProductVariant = cache (
253- async ( variables : VariantVariables , customerAccessToken ?: string ) => {
252+ export const getStreamableProductVariantInventory = cache (
253+ async ( variables : VariantInventoryVariables , customerAccessToken ?: string ) => {
254254 const { data } = await client . fetch ( {
255- document : StreamableProductVariantBySkuQuery ,
255+ document : StreamableProductVariantInventoryBySkuQuery ,
256256 variables,
257257 customerAccessToken,
258- fetchOptions : customerAccessToken ? { cache : 'no-store' } : { next : { revalidate } } ,
258+ fetchOptions : customerAccessToken ? { cache : 'no-store' } : { next : { revalidate : 60 } } ,
259259 } ) ;
260260
261261 return data . site . product ?. variants ;
@@ -311,6 +311,36 @@ const StreamableProductQuery = graphql(
311311 minPurchaseQuantity
312312 maxPurchaseQuantity
313313 warranty
314+ ...ProductViewedFragment
315+ ...ProductSchemaFragment
316+ }
317+ }
318+ }
319+ ` ,
320+ [ ProductViewedFragment , ProductSchemaFragment ] ,
321+ ) ;
322+
323+ type Variables = VariablesOf < typeof StreamableProductQuery > ;
324+
325+ export const getStreamableProduct = cache (
326+ async ( variables : Variables , customerAccessToken ?: string ) => {
327+ const { data } = await client . fetch ( {
328+ document : StreamableProductQuery ,
329+ variables,
330+ customerAccessToken,
331+ fetchOptions : customerAccessToken ? { cache : 'no-store' } : { next : { revalidate } } ,
332+ } ) ;
333+
334+ return data . site . product ;
335+ } ,
336+ ) ;
337+
338+ const StreamableProductInventoryQuery = graphql (
339+ `
340+ query StreamableProductInventoryQuery($entityId: Int!) {
341+ site {
342+ product(entityId: $entityId) {
343+ sku
314344 inventory {
315345 hasVariantInventory
316346 isInStock
@@ -325,25 +355,23 @@ const StreamableProductQuery = graphql(
325355 availabilityV2 {
326356 status
327357 }
328- ...ProductViewedFragment
329358 ...ProductVariantsInventoryFragment
330- ...ProductSchemaFragment
331359 }
332360 }
333361 }
334362 ` ,
335- [ ProductViewedFragment , ProductSchemaFragment , ProductVariantsInventoryFragment ] ,
363+ [ ProductVariantsInventoryFragment ] ,
336364) ;
337365
338- type Variables = VariablesOf < typeof StreamableProductQuery > ;
366+ type ProductInventoryVariables = VariablesOf < typeof StreamableProductQuery > ;
339367
340- export const getStreamableProduct = cache (
341- async ( variables : Variables , customerAccessToken ?: string ) => {
368+ export const getStreamableProductInventory = cache (
369+ async ( variables : ProductInventoryVariables , customerAccessToken ?: string ) => {
342370 const { data } = await client . fetch ( {
343- document : StreamableProductQuery ,
371+ document : StreamableProductInventoryQuery ,
344372 variables,
345373 customerAccessToken,
346- fetchOptions : customerAccessToken ? { cache : 'no-store' } : { next : { revalidate } } ,
374+ fetchOptions : customerAccessToken ? { cache : 'no-store' } : { next : { revalidate : 60 } } ,
347375 } ) ;
348376
349377 return data . site . product ;
0 commit comments