ApolloServer.d.ts 1.5 KB

123456789101112131415161718192021222324252627282930313233
  1. import express from 'express';
  2. import corsMiddleware from 'cors';
  3. import { OptionsJson } from 'body-parser';
  4. import { GraphQLOptions, ApolloServerBase, ContextFunction, Context, Config } from 'apollo-server-core';
  5. import type { ExecutionParams } from 'subscriptions-transport-ws';
  6. export { GraphQLOptions, GraphQLExtension } from 'apollo-server-core';
  7. export 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. }
  14. export interface ServerRegistration extends GetMiddlewareOptions {
  15. app: express.Application;
  16. }
  17. export interface ExpressContext {
  18. req: express.Request;
  19. res: express.Response;
  20. connection?: ExecutionParams;
  21. }
  22. export interface ApolloServerExpressConfig extends Config {
  23. context?: ContextFunction<ExpressContext, Context> | Context;
  24. }
  25. export 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