22 lines
624 B
TypeScript
22 lines
624 B
TypeScript
import "server-only";
|
|
|
|
import { cacheExchange, createClient, fetchExchange } from "@urql/core";
|
|
import { registerUrql } from "@urql/next/rsc";
|
|
|
|
const wagtailBaseUrl = process.env.WAGTAIL_BASE_URL;
|
|
if (!wagtailBaseUrl) {
|
|
throw new Error("WAGTAIL_BASE_URL is not set");
|
|
}
|
|
const graphqlEndpoint = `${wagtailBaseUrl.replace(/\/$/, "")}/api/graphql/`;
|
|
|
|
const makeClient = () => {
|
|
return createClient({
|
|
url: graphqlEndpoint,
|
|
exchanges: [cacheExchange, fetchExchange],
|
|
// requestPolicy: "network-only",
|
|
fetchOptions: { next: { revalidate: 0 } },
|
|
});
|
|
};
|
|
|
|
export const { getClient } = registerUrql(makeClient);
|