Skip to content

Commit a727183

Browse files
committed
feat(products): allow prefetch skipIfCached override
1 parent 5bd3ab3 commit a727183

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

  • libs/storefront-data/src/products

libs/storefront-data/src/products/hooks.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -396,8 +396,10 @@ export function createProductHooks<
396396
const cached = queryClient.getQueryData(queryKey)
397397
const useGlobalFetcher =
398398
prefetchOptions?.useGlobalFetcher && service.getProductsGlobal
399+
const skipIfCachedResolved =
400+
prefetchOptions?.skipIfCached ?? skipIfCached
399401

400-
if (skipIfCached && cached) {
402+
if (skipIfCachedResolved && cached) {
401403
return
402404
}
403405

@@ -432,8 +434,10 @@ export function createProductHooks<
432434
const cached = queryClient.getQueryData(queryKey)
433435
const useGlobalFetcher =
434436
prefetchOptions?.useGlobalFetcher && service.getProductsGlobal
437+
const skipIfCachedResolved =
438+
prefetchOptions?.skipIfCached ?? skipIfCached
435439

436-
if (skipIfCached && cached) {
440+
if (skipIfCachedResolved && cached) {
437441
return
438442
}
439443

@@ -533,8 +537,10 @@ export function createProductHooks<
533537
const detailParams = buildDetail(resolvedInput)
534538
const queryKey = resolvedQueryKeys.detail(detailParams)
535539
const cached = queryClient.getQueryData(queryKey)
540+
const skipIfCachedResolved =
541+
prefetchOptions?.skipIfCached ?? skipIfCached
536542

537-
if (skipIfCached && cached) {
543+
if (skipIfCachedResolved && cached) {
538544
return
539545
}
540546

0 commit comments

Comments
 (0)