UNPKG

1.53 kBTypeScriptView Raw
1import express from 'express';
2import corsMiddleware from 'cors';
3import { OptionsJson } from 'body-parser';
4import { GraphQLOptions, ApolloServerBase, ContextFunction, Context, Config } from 'apollo-server-core';
5import { ExecutionParams } from 'subscriptions-transport-ws';
6export { GraphQLOptions, GraphQLExtension } from 'apollo-server-core';
7export interface GetMiddlewareOptions {
8 path?: string;
9 cors?: corsMiddleware.CorsOptions | corsMiddleware.CorsOptionsDelegate | boolean;
10 bodyParserConfig?: OptionsJson | boolean;
11 onHealthCheck?: (req: express.Request) => Promise<any>;
12 disableHealthCheck?: boolean;
13}
14export interface ServerRegistration extends GetMiddlewareOptions {
15 app: express.Application;
16}
17export interface ExpressContext {
18 req: express.Request;
19 res: express.Response;
20 connection?: ExecutionParams;
21}
22export interface ApolloServerExpressConfig extends Config {
23 context?: ContextFunction<ExpressContext, Context> | Context;
24}
25export declare class ApolloServer extends ApolloServerBase {
26 constructor(config: ApolloServerExpressConfig);
27 createGraphQLServerOptions(req: express.Request, res: express.Response): Promise<GraphQLOptions>;
28 protected supportsSubscriptions(): boolean;
29 protected supportsUploads(): boolean;
30 applyMiddleware({ app, ...rest }: ServerRegistration): void;
31 getMiddleware({ path, cors, bodyParserConfig, disableHealthCheck, onHealthCheck, }?: GetMiddlewareOptions): express.Router;
32}
33//# sourceMappingURL=ApolloServer.d.ts.map
\No newline at end of file