Merged in feat/use-hash-for-graphql-cache (pull request #2251)
Feature: Use hash of query+variables for graphql cache instead of gitsha * feature: use a hash of query+variables as part of the cache key instead of gitsha * . * Merge branch 'master' of bitbucket.org:scandic-swap/web into feat/use-hash-for-graphql-cache * use correct json stringify * merge * remove edgeRequest in favor of request * add more indicative logging Approved-by: Linus Flood
This commit is contained in:
@@ -1,23 +0,0 @@
|
||||
import { getCacheClient } from "@/services/dataCache"
|
||||
import { resolve as resolveEntry } from "@/utils/entry"
|
||||
|
||||
import type { Lang } from "@/constants/languages"
|
||||
|
||||
export const fetchAndCacheEntry = async (path: string, lang: Lang) => {
|
||||
path = path || "/"
|
||||
const cacheKey = `${lang}:resolveentry:${path}`
|
||||
const cache = await getCacheClient()
|
||||
|
||||
return cache.cacheOrGet(
|
||||
cacheKey,
|
||||
async () => {
|
||||
const { contentType, uid } = await resolveEntry(path, lang)
|
||||
|
||||
return {
|
||||
contentType,
|
||||
uid,
|
||||
}
|
||||
},
|
||||
"max"
|
||||
)
|
||||
}
|
||||
@@ -1,10 +1,9 @@
|
||||
import { Lang } from "@/constants/languages"
|
||||
|
||||
import { resolve as resolveEntry } from "@/utils/entry"
|
||||
import { findLang } from "@/utils/languages"
|
||||
import { removeTrailingSlash } from "@/utils/url"
|
||||
|
||||
import { fetchAndCacheEntry } from "./fetchAndCacheEntry"
|
||||
|
||||
export const getUidAndContentTypeByPath = async (pathname: string) => {
|
||||
const lang = findLang(pathname)
|
||||
|
||||
@@ -12,7 +11,7 @@ export const getUidAndContentTypeByPath = async (pathname: string) => {
|
||||
|
||||
const contentTypePathName = pathWithoutTrailingSlash.replace(`/${lang}`, "")
|
||||
|
||||
const { contentType, uid } = await fetchAndCacheEntry(
|
||||
const { contentType, uid } = await resolveEntry(
|
||||
contentTypePathName,
|
||||
lang ?? Lang.en
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user