import { ApolloServer, Config, CreateHandlerOptions, GraphQLOptions } from 'apollo-server-lambda'; import { APIGatewayProxyResult, APIGatewayProxyEvent, Context as LambdaContext, Handler as LambdaHandler } from 'aws-lambda'; import { APIGatewayWebSocketEvent, IConnectionManager, IContext, IEventProcessor, ISubscriptionManager, IConnection, OperationRequest, AppSyncExtensions } from './types'; import { ExecutionParams } from './execute'; interface ExtraGraphQLOptions extends GraphQLOptions { $$internal: IContext['$$internal']; } export interface ServerConfig extends Omit { /** * Connection manager takes care of * - registering/unregistering WebSocket connections * - sending data to connections */ connectionManager: IConnectionManager; context?: object | ((contextParams: IContext) => object | Promise); eventProcessor: IEventProcessor; /** * Use to report errors from web socket handler */ onError?: (err: any) => void; /** * Subscriptions manager takes care of * - registering/unregistering connection's subscribed operations */ subscriptionManager: ISubscriptionManager; subscriptions?: { onOperation?: (message: OperationRequest, params: ExecutionParams, connection: IConnection) => Promise | ExecutionParams; onOperationComplete?: (connection: IConnection, operationId: string) => void; /** * onWebsocketConnect is called when the Websocket connection is initialized ($connect route). * Return an object to set a context to your connection object saved in the database e.g. for saving authentication details. * This is especially useful to get authentication details (API GW authorizers only run in $connect route) * */ onWebsocketConnect?: (connection: IConnection, event: APIGatewayWebSocketEvent, context: LambdaContext) => Promise | boolean | { [key: string]: any; }; /** * onConnect is called when the GraphQL connection is initialized (connection_init message). * Return an object to set a context to your connection object saved in the database e.g. for saving authentication details. * * NOTE: This is not the websocket $connect route, see onWebsocketConnect for the $connect route * */ onConnect?: (messagePayload: { [key: string]: any; } | undefined | null, connection: IConnection, event: APIGatewayWebSocketEvent, context: LambdaContext) => Promise | boolean | { [key: string]: any; }; /** * onStartSubscription is called when the GraphQL subscription is registered on the connection, after initialization. * Return an object to set a context to your connection object saved in the database e.g. for saving authentication details. * */ onStartSubscription?: (messagePayload: { [key: string]: any; } | undefined | null, connection: IConnection, event: APIGatewayWebSocketEvent & { appSyncExtensions?: AppSyncExtensions; }, context: LambdaContext) => Promise | boolean | { [key: string]: any; }; onDisconnect?: (connection: IConnection) => void; /** * If connection is not initialized on GraphQL operation, wait for connection to be initialized * Or throw prohibited connection error * */ waitForInitialization?: { /** * How many times should we try to determine connection state? * * Default is 10 */ retryCount?: number; /** * How long should we wait until we try determine connection state again? * * Default is 50ms */ timeout?: number; }; /** * If specified, the connection endpoint will be registered with this value as opposed to extracted from the event payload * */ connectionEndpoint?: string; /** * Use AppSync pure websockets subscription protocol? */ useAppSync?: boolean; }; } export declare class Server extends ApolloServer { private connectionManager; private eventProcessor; private onError; private subscriptionManager; private subscriptionOptions; constructor({ connectionManager, context, eventProcessor, onError, subscriptionManager, subscriptions, ...restConfig }: ServerConfig); getConnectionManager(): IConnectionManager; getSubscriptionManager(): ISubscriptionManager; createGraphQLServerOptions(event: APIGatewayProxyEvent, context: LambdaContext, internal?: Omit): Promise; /** * Event handler is responsible for processing published events and sending them * to all subscribed connections */ createEventHandler(): TEventHandler; /** * HTTP event handler is responsible for processing AWS API Gateway v1 events */ createHttpHandler(options?: CreateHandlerOptions): (event: APIGatewayProxyEvent, context: LambdaContext) => Promise; /** * WebSocket handler is responsible for processing AWS API Gateway v2 events */ createWebSocketHandler(): (event: APIGatewayWebSocketEvent, context: LambdaContext) => Promise; installSubscriptionHandlers(): void; } export {}; //# sourceMappingURL=Server.d.ts.map