import { execute as graphqlExecute, GraphQLSchema, subscribe as graphqlSubscribe } from 'graphql';
import { ServerOptions } from 'graphql-ws';
/**
 * The members of a `ws` `WebSocketServer` that Nest relies on. Typed
 * structurally, so that the public types of `@nestjs/graphql` don't depend on
 * `@types/ws`: pass a `new WebSocketServer({ noServer: true, ... })` instance.
 */
export interface GraphQLWsServer {
    options: {
        noServer?: boolean;
        path?: string;
    };
    handleUpgrade(request: any, socket: any, upgradeHead: any, callback: (client: any, request: any) => void): void;
    emit(event: 'connection', ...args: any[]): boolean;
}
export type GraphQLWsSubscriptionsConfig = Partial<Pick<ServerOptions, 'connectionInitWaitTimeout' | 'onConnect' | 'onDisconnect' | 'onClose' | 'onSubscribe' | 'onNext' | 'onError' | 'validate'>> & {
    path?: string;
    /**
     * A `ws` WebSocketServer to use instead of the default one, e.g. to set
     * `perMessageDeflate`, `maxPayload` or `verifyClient`.
     *
     * It must be created with `{ noServer: true }`: Nest routes the HTTP
     * upgrade requests to it. Its `path`, when set, takes precedence over
     * `path` above and the GraphQL module path.
     *
     * The server is handed over to graphql-ws, which replaces its
     * `handleProtocols` option and, on application shutdown, closes it and
     * removes all of its listeners. Use a separate server per GraphQL module.
     */
    server?: GraphQLWsServer;
    /**
     * How many milliseconds an upgrade request for another path is left open
     * when another `upgrade` listener on the same server may claim it. A socket
     * that nothing has been written to by then is closed. Raise it when another
     * listener answers the handshake late, for example after a slow
     * authentication, or set it to `0` to leave such sockets to the other
     * listeners entirely.
     *
     * @default 1000
     */
    unclaimedUpgradeTimeout?: number;
};
export type SubscriptionConfig = {
    'graphql-ws'?: GraphQLWsSubscriptionsConfig | boolean;
};
export interface GqlSubscriptionServiceOptions extends SubscriptionConfig {
    schema: GraphQLSchema;
    execute?: typeof graphqlExecute;
    subscribe?: typeof graphqlSubscribe;
    path?: string;
    context?: ServerOptions['context'];
}
export declare class GqlSubscriptionService {
    private readonly options;
    private readonly httpServer;
    private readonly wss;
    private readonly path?;
    private wsGqlDisposable;
    constructor(options: GqlSubscriptionServiceOptions, httpServer: any);
    private initialize;
    stop(): Promise<void>;
}
//# sourceMappingURL=gql-subscription.service.d.ts.map