fix(SW-190): added cache for content page query and added breadcrumbs fetching for content page

This commit is contained in:
Erik Tiekstra
2024-08-16 10:14:45 +02:00
parent 56312335b2
commit b2b7f4f85a
11 changed files with 151 additions and 14 deletions

View File

@@ -4,6 +4,7 @@ import { request } from "@/lib/graphql/request"
import { notFound } from "@/server/errors/trpc"
import { contentstackExtendedProcedureUID, router } from "@/server/trpc"
import { generateTag } from "@/utils/generateTag"
import { makeImageVaultImage } from "@/utils/imageVault"
import { validateContentPageSchema } from "./output"
@@ -21,10 +22,17 @@ export const contentPageQueryRouter = router({
get: contentstackExtendedProcedureUID.query(async ({ ctx }) => {
const { lang, uid } = ctx
const response = await request<ContentPageDataRaw>(GetContentPage, {
locale: lang,
uid,
})
// TODO: Refs request should be done when adding more data to this query
// which has references to other pages.
const response = await request<ContentPageDataRaw>(
GetContentPage,
{
locale: lang,
uid,
},
{ tags: [generateTag(lang, uid)] }
)
if (!response.data) {
throw notFound(response)