import type { WebSocketHandler } from 'bun'; import type { GraphQLSchema } from 'graphql'; /** Per-connection state carried on Bun's `ServerWebSocket.data`. */ export interface GraphqlWsData { protocol: string; request: Request; onMessage?: (data: string) => Promise; closed?: (code: number, reason: string) => void | Promise; } export interface GraphqlWsHandlersOptions { schema: GraphQLSchema; /** * Runs on `connection_init`. Return `false` to reject, or an object merged into * the connection context (surface Better Auth session lookup here for auth). */ onConnect?: (ctx: { connectionParams?: Record; request: Request; }) => boolean | Record | Promise>; /** Build the per-operation GraphQL context. Receives the connection context. */ buildContext?: (connectionContext: Record) => Record | Promise>; } /** * Build Bun WebSocket handlers that speak the `graphql-transport-ws` protocol, * bridging Bun's socket lifecycle to graphql-ws's transport-agnostic server core. * * `upgradeData(request)` produces the `data` payload to pass to `server.upgrade`. */ export declare const createGraphqlWsHandlers: (options: GraphqlWsHandlersOptions) => { websocket: WebSocketHandler; upgradeData: (request: Request) => GraphqlWsData; protocol: string; }; //# sourceMappingURL=ws-transport.d.ts.map