feat: loosen up the zod validations and return null instead of throwing
This commit is contained in:
@@ -8,12 +8,8 @@ import {
|
||||
GetCurrentHeaderRef,
|
||||
} from "@/lib/graphql/Query/CurrentHeader.graphql"
|
||||
import { request } from "@/lib/graphql/request"
|
||||
import { internalServerError, notFound } from "@/server/errors/trpc"
|
||||
import {
|
||||
contentstackBaseProcedure,
|
||||
publicProcedure,
|
||||
router,
|
||||
} from "@/server/trpc"
|
||||
import { notFound } from "@/server/errors/trpc"
|
||||
import { contentstackBaseProcedure, router } from "@/server/trpc"
|
||||
|
||||
import { generateTag } from "@/utils/generateTag"
|
||||
|
||||
@@ -47,12 +43,16 @@ export const baseQueryRouter = router({
|
||||
)
|
||||
|
||||
if (!validatedContactConfigConfig.success) {
|
||||
throw internalServerError(validatedContactConfigConfig.error)
|
||||
console.info(
|
||||
`Failed to validate Contact Config Data - (lang: ${ctx.lang})`
|
||||
)
|
||||
console.error(validatedContactConfigConfig.error)
|
||||
return null
|
||||
}
|
||||
|
||||
return validatedContactConfigConfig.data.all_contact_config.items[0]
|
||||
}),
|
||||
header: publicProcedure.input(langInput).query(async ({ input }) => {
|
||||
header: contentstackBaseProcedure.input(langInput).query(async ({ input }) => {
|
||||
const responseRef = await request<HeaderRefDataRaw>(GetCurrentHeaderRef, {
|
||||
locale: input.lang,
|
||||
})
|
||||
@@ -79,7 +79,9 @@ export const baseQueryRouter = router({
|
||||
)
|
||||
|
||||
if (!validatedHeaderConfig.success) {
|
||||
throw internalServerError(validatedHeaderConfig.error)
|
||||
console.info(`Failed to validate Header - (lang: ${input.lang})`)
|
||||
console.error(validatedHeaderConfig.error)
|
||||
return null
|
||||
}
|
||||
|
||||
const logo =
|
||||
@@ -91,7 +93,7 @@ export const baseQueryRouter = router({
|
||||
logo,
|
||||
} as HeaderData
|
||||
}),
|
||||
footer: publicProcedure.input(langInput).query(async ({ input }) => {
|
||||
footer: contentstackBaseProcedure.input(langInput).query(async ({ input }) => {
|
||||
const responseRef = await request<FooterRefDataRaw>(GetCurrentFooterRef, {
|
||||
locale: input.lang,
|
||||
})
|
||||
@@ -116,7 +118,9 @@ export const baseQueryRouter = router({
|
||||
)
|
||||
|
||||
if (!validatedFooterConfig.success) {
|
||||
throw internalServerError(validatedFooterConfig.error)
|
||||
console.info(`Failed to validate Footer - (lang: ${input.lang})`)
|
||||
console.error(validatedFooterConfig.error)
|
||||
return null
|
||||
}
|
||||
|
||||
return validatedFooterConfig.data.all_current_footer.items[0]
|
||||
|
||||
Reference in New Issue
Block a user