/// import { EventEmitter } from 'events'; import { GraphQLResolveInfo } from 'graphql'; import { IDebugger } from '@cortexql/core'; import { Request } from 'express'; import * as WebSocket from 'ws'; import { OperationMessage, ExecutionParams } from 'subscriptions-transport-ws'; import { GraphQLSchema, DocumentNode, ExecutionResult } from 'graphql'; export interface ContextExecute { (document: DocumentNode, variableValues?: { [key: string]: any; }, operationName?: string): Promise; } export interface ContextSubscribe { (document: DocumentNode, variableValues?: { [key: string]: any; }, operationName?: string): Promise>; } export interface ContextParams { [key: string]: any; } export declare function createContextId(context: BaseContext): any; export declare function createExecutionContextId(context: BaseContext, info?: GraphQLResolveInfo): any; export declare function createContextNamespace(context: BaseContext, info?: GraphQLResolveInfo, id?: any): string; export declare class BaseContext { params: ContextParams; operationName: string | undefined; operationType: string | undefined; id: any; schema: GraphQLSchema; event: EventEmitter; executionEvent?: EventEmitter; execute: ContextExecute; subscribe: ContextSubscribe; context?: this; completed: boolean; completionError?: Error; completionReason?: string; isExecution: false; destroy(handler: (...args: any[]) => void): EventEmitter; on(event: string, handler: (...args: any[]) => void): EventEmitter; once(event: string, handler: (...args: any[]) => void): EventEmitter; removeListener(event: string, handler: (...args: any[]) => void): EventEmitter; removeAllListeners(event: string): EventEmitter; emit(event: string, ...args: any[]): boolean; constructor(params: ContextParams, operationName?: string | undefined, operationType?: string | undefined, id?: any); debug: IDebugger; execution(info?: GraphQLResolveInfo): Promise>; endAll(): void; endAll(error: Error | null | undefined, reason?: string): void; endAll(handler: (error?: Error | null | undefined, reason?: string) => void): Promise; end(): void; end(error: Error | null | undefined, reason?: string): void; end(handler: (error?: Error | null | undefined, reason?: string) => void): Promise; } export declare class BaseExecutionContext { context: T; info: GraphQLResolveInfo | undefined; executionEvent: EventEmitter; isExecution: boolean; id: any; debug: IDebugger; completed: boolean; completionError?: Error; completionReason?: string; execution(info?: GraphQLResolveInfo | undefined): Promise>; constructor(context: T, info?: GraphQLResolveInfo | undefined); destroy(handler: (...args: any[]) => void): EventEmitter; on(event: string, handler: (...args: any[]) => void): EventEmitter; once(event: string, handler: (...args: any[]) => void): EventEmitter; removeListener(event: string, handler: (...args: any[]) => void): EventEmitter; removeAllListeners(event: string): EventEmitter; emit(event: string, ...args: any[]): boolean; end(): void; end(error: Error | null | undefined, reason?: string): void; end(handler: (error?: Error | null | undefined, reason?: string) => void): Promise; } export declare type ExecutionContext = T & BaseExecutionContext; export declare function createContext(params: ContextParams, operationName?: string, operationType?: string, executionId?: any): Promise; export declare function createExecutionContext(context: T, info?: GraphQLResolveInfo): Promise>; export declare function getOperationFromQuery(query: string): { operationName: string; operationType: string; } | { operationName: undefined; operationType: undefined; }; export declare function createContextFromExpressRequest(req: Request, params?: ContextParams): Promise; export declare function createContextFromWebSocketTransport(webSocket: WebSocket, message: OperationMessage, params: ExecutionParams): Promise;