diff --git a/apps/scandic-web/lib/graphql/request.ts b/apps/scandic-web/lib/graphql/request.ts index b7e036c2c..eb2c40a12 100644 --- a/apps/scandic-web/lib/graphql/request.ts +++ b/apps/scandic-web/lib/graphql/request.ts @@ -21,12 +21,22 @@ export async function request( ttl: CacheTime } ): Promise> { - const doCall = () => internalRequest(query, variables) + const shouldUsePreview = variables?.uid + ? isPreviewByUid(variables.uid) + : false + + const doCall = () => internalRequest(query, shouldUsePreview, variables) + if (!cacheOptions) { console.warn("[NO CACHE] for query", query) return doCall() } + if (shouldUsePreview) { + console.log("[NO CACHE] [PREVIEW] for query", query) + return doCall() + } + const cacheKey: string = Array.isArray(cacheOptions.key) ? cacheOptions.key.join("_") : cacheOptions.key @@ -37,11 +47,9 @@ export async function request( function internalRequest( query: string | DocumentNode, + shouldUsePreview: boolean, variables?: Record ): Promise> { - const shouldUsePreview = variables?.uid - ? isPreviewByUid(variables.uid) - : false const previewHash = getPreviewHash() const cmsUrl = shouldUsePreview ? env.CMS_PREVIEW_URL : env.CMS_URL