UNPKG

@nestjs/graphql

Version:

Nest - modern, fast, powerful node.js web framework (@graphql)

52 lines • 2.21 kB
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; }; 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