UNPKG

@graphql-tools/executor-graphql-ws

Version:

A set of utils for faster development of GraphQL tools

41 lines (38 loc) 1.61 kB
import { DisposableAsyncExecutor } from '@graphql-tools/utils'; import { print } from 'graphql'; import { Client } from 'graphql-ws'; interface GraphQLWSExecutorOptions { onClient?: (client: Client) => void; print?: typeof print; /** The URL of the WebSocket server to connect to. */ url: string; /** * Additional headers to include with the upgrade request. * It will never be sent again during the lifecycle of the socket. * * Warning: This is a noop in browser environments */ headers?: Record<string, string>; /** * Optional parameters, passed through the `payload` field with the `ConnectionInit` message, * that the client specifies when establishing a connection with the server. You can use this * for securely passing arguments for authentication. */ connectionParams?: Record<string, unknown> | (() => Record<string, unknown>); /** * How to establish the connection to the server, on-demand or eagerly. * * @default true */ lazy?: boolean; /** * How long should the client wait before closing the socket after the last operation has * completed. This is meant to be used in combination with `lazy`. You might want to have * a calmdown time before actually closing the connection. Kinda' like a lazy close "debounce". * * @default 0 */ lazyCloseTimeout?: number; } declare function buildGraphQLWSExecutor(clientOptionsOrClient: GraphQLWSExecutorOptions | Client): DisposableAsyncExecutor; export { type GraphQLWSExecutorOptions, buildGraphQLWSExecutor };