export async function fetchGraphQL(query: string, variables = {}) {
  const res = await fetch(
    process.env.NEXT_PUBLIC_WP_GRAPHQL_URL!,
    {
      method: "POST",
      headers: {
        "Content-Type": "application/json",
      },
      body: JSON.stringify({
        query,
        variables,
      }),
      next: { revalidate: 300 }, // ISR
    }
  );

  if (!res.ok) {
    throw new Error("Failed to fetch GraphQL");
  }

  return res.json();
}
