feat: revalidate my pages breadcrumbs on demand

This commit is contained in:
Simon Emanuelsson
2024-04-16 12:42:44 +02:00
committed by Michael Zetterberg
parent ba13a00b63
commit 0c4aa592cc
24 changed files with 322 additions and 57 deletions
+7 -3
View File
@@ -10,6 +10,7 @@ import type { DocumentNode } from "graphql"
import type { Data } from "@/types/request"
const client = new GraphQLClient(env.CMS_URL, {
cache: "force-cache",
fetch: cache(async function (
url: URL | RequestInfo,
params: RequestInit | undefined
@@ -21,11 +22,14 @@ const client = new GraphQLClient(env.CMS_URL, {
export async function request<T>(
query: string | DocumentNode,
variables?: {},
next?: NextFetchRequestConfig
options?: Pick<RequestInit, "cache" | "next">
): Promise<Data<T>> {
try {
if (next) {
client.requestConfig.next = next
if (options?.cache) {
client.requestConfig.cache = options.cache
}
if (options?.next) {
client.requestConfig.next = options.next
}
if (env.PRINT_QUERY) {