"use client";

import { useMemo, type ReactNode } from "react";
import { Provider } from "urql";
import { createGraphQLClient } from "@/lib/graphql-client";

/**
 * GraphQL Provider（standalone 模式自建 urql client）
 *
 * 仲裁 ARB-002 / ISSUE-047 §5.4：MF 模式复用 Shell 暴露的 GraphQL client 单例
 * 开发期 standalone 模式：自建 urql client 指向 /api/admin/graphql（MSW 拦截）
 */
export function GraphQLProvider({ children }: { children: ReactNode }) {
  const client = useMemo(() => createGraphQLClient(), []);
  return <Provider value={client}>{children}</Provider>;
}
