/*** UTILITY ------------------------------------------ ***/ import { buildHeaders, postJson } from "./http-body.ts"; import type { Fetcher, FetcherOptions } from "./types.ts"; /*** EXPORT ------------------------------------------- ***/ export function createHttpFetcher(options: FetcherOptions): Fetcher { const fetchImpl = options.fetch ?? globalThis.fetch; return async (req) => { return await postJson(fetchImpl, options.url, buildHeaders(options, req), { operationName: req.operationName, query: req.query, variables: req.variables }); }; }