fix(SW-438): divide pageRefs query into two due to size limitations
This commit is contained in:
@@ -83,16 +83,6 @@ query GetContentPageRefs($locale: String!, $uid: String!) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
blocks {
|
|
||||||
__typename
|
|
||||||
...Accordion_ContentPageRefs
|
|
||||||
...CardsGrid_ContentPageRefs
|
|
||||||
...Content_ContentPageRefs
|
|
||||||
...DynamicContent_ContentPageRefs
|
|
||||||
...Shortcuts_ContentPageRefs
|
|
||||||
...TextCols_ContentPageRef
|
|
||||||
...UspGrid_ContentPageRefs
|
|
||||||
}
|
|
||||||
sidebar {
|
sidebar {
|
||||||
__typename
|
__typename
|
||||||
...ContentSidebar_ContentPageRefs
|
...ContentSidebar_ContentPageRefs
|
||||||
@@ -107,6 +97,21 @@ query GetContentPageRefs($locale: String!, $uid: String!) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
query GetContentPageBlocksRefs($locale: String!, $uid: String!) {
|
||||||
|
content_page(locale: $locale, uid: $uid) {
|
||||||
|
blocks {
|
||||||
|
__typename
|
||||||
|
...Accordion_ContentPageRefs
|
||||||
|
...CardsGrid_ContentPageRefs
|
||||||
|
...Content_ContentPageRefs
|
||||||
|
...DynamicContent_ContentPageRefs
|
||||||
|
...Shortcuts_ContentPageRefs
|
||||||
|
...TextCols_ContentPageRef
|
||||||
|
...UspGrid_ContentPageRefs
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
query GetDaDeEnUrlsContentPage($uid: String!) {
|
query GetDaDeEnUrlsContentPage($uid: String!) {
|
||||||
de: content_page(locale: "de", uid: $uid) {
|
de: content_page(locale: "de", uid: $uid) {
|
||||||
url
|
url
|
||||||
|
|||||||
@@ -1,7 +1,10 @@
|
|||||||
import { metrics } from "@opentelemetry/api"
|
import { metrics } from "@opentelemetry/api"
|
||||||
|
|
||||||
import { Lang } from "@/constants/languages"
|
import { Lang } from "@/constants/languages"
|
||||||
import { GetContentPageRefs } from "@/lib/graphql/Query/ContentPage/ContentPage.graphql"
|
import {
|
||||||
|
GetContentPageBlocksRefs,
|
||||||
|
GetContentPageRefs,
|
||||||
|
} from "@/lib/graphql/Query/ContentPage/ContentPage.graphql"
|
||||||
import { request } from "@/lib/graphql/request"
|
import { request } from "@/lib/graphql/request"
|
||||||
import { notFound } from "@/server/errors/trpc"
|
import { notFound } from "@/server/errors/trpc"
|
||||||
|
|
||||||
@@ -41,18 +44,30 @@ export async function fetchContentPageRefs(lang: Lang, uid: string) {
|
|||||||
query: { lang, uid },
|
query: { lang, uid },
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
const refsResponse = await request<GetContentPageRefsSchema>(
|
const [mainRefsResponse, blockRefsResponse] = await Promise.all([
|
||||||
GetContentPageRefs,
|
request<GetContentPageRefsSchema>(
|
||||||
{ locale: lang, uid },
|
GetContentPageRefs,
|
||||||
{
|
{ locale: lang, uid },
|
||||||
cache: "force-cache",
|
{
|
||||||
next: {
|
cache: "force-cache",
|
||||||
tags: [generateTag(lang, uid)],
|
next: {
|
||||||
},
|
tags: [generateTag(lang, uid)],
|
||||||
}
|
},
|
||||||
)
|
}
|
||||||
if (!refsResponse.data) {
|
),
|
||||||
const notFoundError = notFound(refsResponse)
|
request<GetContentPageRefsSchema>(
|
||||||
|
GetContentPageBlocksRefs,
|
||||||
|
{ locale: lang, uid },
|
||||||
|
{
|
||||||
|
cache: "force-cache",
|
||||||
|
next: {
|
||||||
|
tags: [generateTag(lang, uid)],
|
||||||
|
},
|
||||||
|
}
|
||||||
|
),
|
||||||
|
])
|
||||||
|
if (!mainRefsResponse.data) {
|
||||||
|
const notFoundError = notFound(mainRefsResponse)
|
||||||
getContentPageRefsFailCounter.add(1, {
|
getContentPageRefsFailCounter.add(1, {
|
||||||
lang,
|
lang,
|
||||||
uid,
|
uid,
|
||||||
@@ -73,8 +88,14 @@ export async function fetchContentPageRefs(lang: Lang, uid: string) {
|
|||||||
)
|
)
|
||||||
throw notFoundError
|
throw notFoundError
|
||||||
}
|
}
|
||||||
|
const responseData = {
|
||||||
return refsResponse.data
|
...mainRefsResponse.data,
|
||||||
|
content_page: {
|
||||||
|
...mainRefsResponse.data.content_page,
|
||||||
|
blocks: blockRefsResponse.data.content_page.blocks,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
return responseData
|
||||||
}
|
}
|
||||||
|
|
||||||
export function validateContentPageRefs(
|
export function validateContentPageRefs(
|
||||||
|
|||||||
Reference in New Issue
Block a user