UNPKG

@yeskiy/federation-with-subscriptions

Version:
40 lines (39 loc) 1.42 kB
/// <reference types="node" /> import { ExpressContext } from "apollo-server-express"; import { ExecutionArgs } from "graphql"; import { Context, SubscribeMessage } from "graphql-ws"; import http from "http"; import WebSocket from "ws"; declare type Headers = Record<string, string | undefined | unknown>; declare type ContextParams = { req: any; res: any; }; declare type GatewayContext<TContext> = { context?: (contextParams: ContextParams) => TContext; }; declare type GatewayParameters = { port?: number; host?: string; path?: string; microservices: { url: string; }[]; onWebsocketMessage?: (message: WebSocket.RawData, context: any) => void; onWebsocketClose?: (context: any) => void; buildHttpHeaders?: ({ req, res, }: { req: ExpressContext["req"] | undefined; res: ExpressContext["res"] | undefined; }) => Promise<Headers> | Headers; buildSubscriptionHeaders?: (context: Context, message: SubscribeMessage, args: ExecutionArgs) => Promise<Headers> | Headers; } & GatewayContext<any>; export declare const createGateway: (params: GatewayParameters) => Promise<{ app: import("express-serve-static-core").Express; server: http.Server; url: string; executableSchema: import("graphql").GraphQLSchema; sdl: (options?: { withDirectives?: boolean; }) => string; }>; export {};