Merged in fix/LOY-400-make-contentstack-data-optional (pull request #3266)
fix(LOY-400): made contentstack data optional so the whole page does not crash if it's empty. * fix(LOY-400): made contentstack data optional so the whole page does not crash if it's empty. * Merged in fix/LOY-400-make-contentstack-data-optional-2 (pull request #3269) Fix/LOY-400 make contentstack data optional 2 * Test * . * Correct ref tag * refactor * Correct key * fix(LOY-400): cleaned up Approved-by: Linus Flood Approved-by: Matilda Landström
This commit is contained in:
@@ -8,17 +8,22 @@ import {
|
||||
} from "../../../graphql/Query/UsePointsModal.graphql"
|
||||
import { request } from "../../../graphql/request"
|
||||
import { contentstackBaseProcedure } from "../../../procedures"
|
||||
import {
|
||||
generateRefsResponseTag,
|
||||
generateTag,
|
||||
generateTagsFromSystem,
|
||||
} from "../../../utils/generateTag"
|
||||
import {
|
||||
type UsePointsModalData,
|
||||
type UsePointsModalRefsData,
|
||||
usePointsModalRefsSchema,
|
||||
usePointsModalSchema,
|
||||
} from "./output"
|
||||
import { getConnections } from "./utils"
|
||||
|
||||
export const usePointsModalQueryRouter = router({
|
||||
get: contentstackBaseProcedure.query(async ({ ctx }) => {
|
||||
const { lang, uid } = ctx
|
||||
|
||||
const getRefsCounter = createCounter(
|
||||
"trpc.contentstack",
|
||||
"usePointsModal.get.refs"
|
||||
@@ -29,11 +34,12 @@ export const usePointsModalQueryRouter = router({
|
||||
})
|
||||
|
||||
metricsRefs.start()
|
||||
const refsTag = generateRefsResponseTag(lang, "usepointsmodal")
|
||||
const refsResponse = await request<UsePointsModalRefsData>(
|
||||
GetUsePointsModalRefs,
|
||||
{ locale: lang },
|
||||
{
|
||||
key: `contentstack:usePointsModal:${lang}:refs`,
|
||||
key: refsTag,
|
||||
ttl: "max",
|
||||
}
|
||||
)
|
||||
@@ -62,11 +68,18 @@ export const usePointsModalQueryRouter = router({
|
||||
})
|
||||
metrics.start()
|
||||
|
||||
const connections = getConnections(validatedRefsData.data)
|
||||
|
||||
const tags = [
|
||||
generateTagsFromSystem(lang, connections),
|
||||
generateTag(lang, "usepointsmodal"),
|
||||
].flat()
|
||||
|
||||
const response = await request<UsePointsModalData>(
|
||||
GetUsePointsModal,
|
||||
{ locale: lang },
|
||||
{
|
||||
key: `contentstack:usePointsModal:${lang}`,
|
||||
key: tags,
|
||||
ttl: "max",
|
||||
}
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user