import "server-only";

import { cacheExchange, createClient, fetchExchange } from "@urql/core";
import { registerUrql } from "@urql/next/rsc";

const makeClient = () => {
  return createClient({
    url: process.env.GRAPHQL_ENDPOINT ?? "",
    exchanges: [cacheExchange, fetchExchange],
    // requestPolicy: "network-only",
    fetchOptions: { next: { revalidate: 0 } },
  });
};

export const { getClient } = registerUrql(makeClient);
