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:
@@ -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",
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user