import { ApolloClient } from '@apollo/client/core'; import { type IGraphQLClientOptions, GraphQLConnectionState } from './types.js'; /** * Function returned by createGraphQLClient that tears down the WebSocket client and stops the Apollo client. * @example * const { client, dispose } = createGraphQLClient(options); * // Later, when cleaning up: * dispose(); */ export type TDisposeFunction = () => void; /** * Result object returned when creating a GraphQL client. * Contains the configured Apollo Client and connection state provider. * @example * const result = createGraphQLClient(options); * const { client, dispose, getConnectionState, onStateChange } = result; * * // Use the client with Apollo * const currentState = getConnectionState(); * * // Subscribe to state changes * const unsubscribe = onStateChange((state) => { * logger.info('Connection state changed:', { state }); * }); */ export interface IGraphQLClientResult { /** Configured Apollo Client instance ready to pass to `ApolloProvider` or use directly. */ client: ApolloClient; /** Stops the WebSocket connection and Apollo Client. Call on teardown. */ dispose: TDisposeFunction; /** Returns the current connection state without subscribing. */ getConnectionState: () => GraphQLConnectionState; /** Subscribes to connection state changes. Returns an unsubscribe function. */ onStateChange: (handler: (state: GraphQLConnectionState) => void) => () => void; } /** * Creates a configured Apollo Client with HTTP and WebSocket transport. * Supports automatic reconnection with exponential backoff, connection state tracking, and error logging. * @param options - Configuration options for the client. * @returns Configured Apollo Client with connection state provider. * @throws {GraphQLClientError} GRAPHQL_INSECURE_WEBSOCKET - If WebSocket URI uses ws:// (insecure) for non-localhost endpoints. * @throws {GraphQLClientError} GRAPHQL_INSECURE_HTTP - If HTTP URI does not use https:// for non-localhost endpoints. * @example * const result = createGraphQLClient({ * httpUri: 'https://api.example.com/graphql', * wsUri: 'wss://api.example.com/graphql', * token: 'Bearer token-value' * }); */ export declare function createGraphQLClient(options: IGraphQLClientOptions): IGraphQLClientResult; //# sourceMappingURL=client.d.ts.map