Merged in feat/rework-contentstack (pull request #3493)

Feat(SW-3708): refactor contentstack fetching (removing all refs) and cache invalidation

* Remove all REFS

* Revalidate correct language

* PR fixes

* PR fixes

* Throw when errors from contentstack api


Approved-by: Joakim Jäderberg
This commit is contained in:
Linus Flood
2026-01-27 12:38:36 +00:00
parent a5e214f783
commit 5fc93472f4
193 changed files with 489 additions and 9018 deletions

View File

@@ -8,8 +8,8 @@ import {
GetContentPageBlocksBatch2,
} from "../../../graphql/Query/ContentPage/ContentPage.graphql"
import { contentstackExtendedProcedureUID } from "../../../procedures"
import { generateTag } from "../../../utils/generateTag"
import { contentPageSchema } from "./output"
import { fetchContentPageRefs, generatePageTags } from "./utils"
import type { GetContentPageSchema } from "../../../types/contentPage"
import type { TrackingPageData } from "../../types"
@@ -18,13 +18,8 @@ export const contentPageQueryRouter = router({
get: contentstackExtendedProcedureUID.query(async ({ ctx }) => {
const { lang, uid } = ctx
const contentPageRefs = await fetchContentPageRefs(lang, uid)
if (!contentPageRefs) {
return null
}
const tags = generatePageTags(contentPageRefs, lang)
// by fetching references when a child entry is published
const cacheKey = generateTag(lang, uid)
const getContentPageCounter = createCounter(
"trpc.contentstack.contentPage.get"
@@ -41,7 +36,7 @@ export const contentPageQueryRouter = router({
document: GetContentPage,
variables: { locale: lang, uid },
cacheOptions: {
key: `${tags.join(",")}:contentPage`,
key: `${cacheKey}:contentPage`,
ttl: "max",
},
},
@@ -50,7 +45,7 @@ export const contentPageQueryRouter = router({
document: GetContentPageBlocksBatch1,
variables: { locale: lang, uid },
cacheOptions: {
key: `${tags.join(",")}:contentPageBlocksBatch1`,
key: `${cacheKey}:contentPageBlocksBatch1`,
ttl: "max",
},
},
@@ -59,7 +54,7 @@ export const contentPageQueryRouter = router({
document: GetContentPageBlocksBatch2,
variables: { locale: lang, uid },
cacheOptions: {
key: `${tags.join(",")}:contentPageBlocksBatch2`,
key: `${cacheKey}:contentPageBlocksBatch2`,
ttl: "max",
},
},