import React from 'react';
import { type IGraphQLClientOptions, GraphQLConnectionState } from './types.js';
/**
* Context value type for GraphQL connection state and reconnection.
* Provides access to the current connection state and a function to manually trigger reconnection.
*/
export interface IGraphQLContextValue {
/** Current GraphQL WebSocket connection state. */
connectionState: GraphQLConnectionState;
/** Function to manually trigger a reconnection attempt. */
reconnect: () => void;
}
/**
* React hook that provides access to the GraphQL context value.
* Must be called within a GraphQLProvider.
* @returns The GraphQL context value containing connection state and reconnect function.
* @throws {GraphQLClientError} GRAPHQL_CONTEXT_NOT_FOUND - If called outside of GraphQLProvider.
* @example
* function ConnectionDebugPanel() {
* const { connectionState, reconnect } = useGraphQLContext();
*
* return (
*
*
State: {connectionState}
*
*
* );
* }
*/
export declare function useGraphQLContext(): IGraphQLContextValue;
/**
* Props for the GraphQL provider component.
* @example
* const props: IGraphQLProviderProps = {
* options: {
* httpUri: 'https://api.example.com/graphql',
* wsUri: 'wss://api.example.com/graphql',
* token: 'Bearer token-value'
* },
* children: ,
* fallback:
* };
*/
export interface IGraphQLProviderProps {
/** GraphQL client configuration options. */
options: IGraphQLClientOptions;
/** React child elements to wrap with the GraphQL provider. */
children: React.ReactNode;
/** Optional fallback UI to display while the client is initializing. */
fallback?: React.ReactNode;
}
/**
* React Provider component that sets up Apollo Client with HTTP and WebSocket transport.
* Manages connection state, automatic reconnection, and provides context to child components.
*
* For optimal performance, pass stable options (memoized or static) to prevent unnecessary client
* recreation. If options.token is a function, it should be stable across re-renders or wrapped
* in useCallback. The implementation uses a defensive ref-based approach to handle unstable options,
* but passing stable options is the recommended pattern.
*
* @param props - Provider configuration and children.
* @returns React element providing GraphQL client context to children.
* @example
* localStorage.getItem('auth-token')
* }}
* fallback={}
* >
*
*
*/
export declare function GraphQLProvider({ options, children, fallback }: IGraphQLProviderProps): React.ReactElement;
//# sourceMappingURL=provider.d.ts.map