feat: loosen up the zod validations and return null instead of throwing
This commit is contained in:
@@ -3,7 +3,7 @@ import {
|
||||
GetNavigationMyPagesRefs,
|
||||
} from "@/lib/graphql/Query/NavigationMyPages.graphql"
|
||||
import { request } from "@/lib/graphql/request"
|
||||
import { internalServerError, notFound } from "@/server/errors/trpc"
|
||||
import { notFound } from "@/server/errors/trpc"
|
||||
import { contentstackBaseProcedure, router } from "@/server/trpc"
|
||||
|
||||
import {
|
||||
@@ -71,7 +71,11 @@ export const navigationQueryRouter = router({
|
||||
const validatedMyPagesNavigationRefs =
|
||||
navigationRefsPayloadSchema.safeParse(refsResponse.data)
|
||||
if (!validatedMyPagesNavigationRefs.success) {
|
||||
throw internalServerError(validatedMyPagesNavigationRefs.error)
|
||||
console.info(
|
||||
`Failed to validate My Pages Navigation Refs - (lang: ${lang}`
|
||||
)
|
||||
console.error(validatedMyPagesNavigationRefs.error)
|
||||
return null
|
||||
}
|
||||
|
||||
const connections = getConnections(validatedMyPagesNavigationRefs.data)
|
||||
@@ -99,7 +103,11 @@ export const navigationQueryRouter = router({
|
||||
response.data
|
||||
)
|
||||
if (!validatedMyPagesNavigation.success) {
|
||||
throw internalServerError(validatedMyPagesNavigation.error)
|
||||
console.info(
|
||||
`Failed to validate My Pages Navigation Data - (lang: ${lang}`
|
||||
)
|
||||
console.error(validatedMyPagesNavigation.error)
|
||||
return null
|
||||
}
|
||||
|
||||
const menuItem =
|
||||
@@ -112,7 +120,11 @@ export const navigationQueryRouter = router({
|
||||
|
||||
const validatedNav = getNavigationSchema.safeParse(nav)
|
||||
if (!validatedNav.success) {
|
||||
throw internalServerError(validatedNav.error)
|
||||
console.info(
|
||||
`Failed to validate My Pages Navigation Return Data - (lang: ${lang}`
|
||||
)
|
||||
console.error(validatedNav.error)
|
||||
return null
|
||||
}
|
||||
|
||||
return validatedNav.data
|
||||
|
||||
Reference in New Issue
Block a user