import { FetchOptions } from 'ofetch'; import { DocumentNode } from 'graphql'; import { ClientOptions, ExecutionResult } from 'graphql-ws'; export { c as GqlError, G as GqlOperation, b as GqlResponse, a as GraphQLError } from './types-5ff68c30.js'; type GqlMiddleware = { onRequest?: FetchOptions['onRequest']; onResponse?: FetchOptions['onResponse']; onRequestError?: FetchOptions['onRequestError']; onResponseError?: FetchOptions['onResponseError']; }; type WSClientOptions = Partial>; type WSNextHandler = (result: ExecutionResult) => void; type WSErrorHandler = (err: Error) => void; type WSOutput = { /** * Restart the WebSocket connection. */ restart: () => void; /** * Initiate the WebSocket connection and listens for events. */ subscribe: () => void; /** * Destroy the WebSocket connection. */ unsubscribe: () => void; /** * onResult is called with the result of the subscription. * * Must be called before `subscribe`. * * @param {WSNextHandler} cb - The callback to be called when a new result is received. */ onResult: (cb: WSNextHandler) => void; /** * onError accepts a callback that is triggered when an error occurs. * * Must be called before `subscribe`. */ onError: (cb: WSErrorHandler) => void; /** * Triggers when the WebSocket connection has completed. */ onComplete: (cb: () => void) => void; }; declare const GqlClient: (input: string | { host: string; wsHost?: string; wsOptions?: WSClientOptions; middleware?: GqlMiddleware; useGETForQueries?: boolean; headers?: Record; }) => { execute: { (opts: { query: string | DocumentNode; variables?: any | Record; headers?: HeadersInit; }): Promise; (query: string | DocumentNode, variables?: any | Record, headers?: HeadersInit): Promise; }; subscribe: { (opts: { query: string | DocumentNode; variables?: Record | null; options?: WSClientOptions; }): WSOutput; (query: string | DocumentNode, variables?: Record | null, options?: WSClientOptions): WSOutput; }; setHost: (host: string) => void; setOptions: (opts?: null | Pick, 'retry' | 'headers' | 'mode' | 'cache' | 'credentials'>) => void; setHeaders: (headers?: FetchOptions['headers']) => void; setMiddleware: (mw: GqlMiddleware) => void; }; type GqlClient = ReturnType; export { GqlClient, GqlMiddleware, WSClientOptions, WSOutput };