More memoized requests

This commit is contained in:
Linus Flood
2024-10-28 11:20:59 +01:00
parent f5798562cc
commit 5e8efb4a27
8 changed files with 44 additions and 24 deletions

View File

@@ -1,3 +1,5 @@
import { cache } from "react"
import { Lang } from "@/constants/languages"
import { GetContactConfig } from "@/lib/graphql/Query/ContactConfig.graphql"
import {
@@ -92,7 +94,7 @@ import type {
GetSiteConfigRefData,
} from "@/types/trpc/routers/contentstack/siteConfig"
async function getContactConfig(lang: Lang) {
const getContactConfig = cache(async (lang: Lang) => {
getContactConfigCounter.add(1, { lang })
console.info(
"contentstack.contactConfig start",
@@ -153,7 +155,7 @@ async function getContactConfig(lang: Lang) {
JSON.stringify({ query: { lang } })
)
return validatedContactConfigConfig.data.all_contact_config.items[0]
}
})
export const baseQueryRouter = router({
contact: contentstackBaseProcedure.query(async ({ ctx }) => {