UNPKG

@gqlts/runtime

Version:

Gqlts runtime client

42 lines 1.69 kB
import { BatchOptions } from '../fetcher'; import { LinkedType } from '../types'; import { GraphqlOperation } from './generateGraphqlOperation'; import { AxiosInstance, AxiosRequestConfig } from 'axios'; import { Client as WSClient, ClientOptions as WSClientOptions } from 'graphql-ws'; type HeaderValue = string | string[] | number | boolean | null; type RawHeaders = Record<string, HeaderValue>; export type Headers = RawHeaders | (() => RawHeaders) | (() => Promise<RawHeaders>); export interface ClientRequestConfig<D = any> extends AxiosRequestConfig<D> { headers?: RawHeaders; } export type BaseFetcher = { fetcherMethod: (operation: GraphqlOperation | GraphqlOperation[], config?: ClientRequestConfig) => Promise<any>; fetcherInstance: AxiosInstance | unknown | undefined; }; export type ClientOptions = Omit<ClientRequestConfig, 'body' | 'headers'> & { url?: string; timeout?: number; batch?: BatchOptions | boolean; fetcherMethod?: BaseFetcher['fetcherMethod']; fetcherInstance?: BaseFetcher['fetcherInstance']; headers?: Headers; subscription?: { url?: string; headers?: Headers; } & Partial<WSClientOptions>; webSocketImpl?: unknown; }; export declare function createClient({ queryRoot, mutationRoot, subscriptionRoot, ...options }: ClientOptions & { queryRoot?: LinkedType; mutationRoot?: LinkedType; subscriptionRoot?: LinkedType; }): { wsClient?: WSClient; query?: Function; mutation?: Function; subscription?: Function; fetcherInstance: BaseFetcher["fetcherInstance"]; fetcherMethod: BaseFetcher["fetcherMethod"]; }; export {}; //# sourceMappingURL=createClient.d.ts.map