diff --git a/CHANGELOG.md b/CHANGELOG.md index 86e24e413bb..7bb572c6e73 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ # vNEXT +- `apollo-server`: Support `onHealthCheck` in the `ApolloServer` constructor in the same way as `cors` is supported. This contrasts with the `-express`, `-hapi`, etc. variations which accept this parameter via their `applyMiddleware` methods and will remain as-is. [PR #2672](https://github.com/apollographql/apollo-server/pull/2672) - core: Expose SHA-256 hex hash digest of the Engine API key to plugins, when available, as `engine.apiKeyHash`. [PR# 2685](https://github.com/apollographql/apollo-server/pull/2685) - `apollo-datasource-rest`: If another `Content-type` is already set on the response, don't overwrite it with `application/json`, allowing the user's initial `Content-type` to prevail. [PR #2520](https://github.com/apollographql/apollo-server/issues/2035) diff --git a/packages/apollo-server/src/index.ts b/packages/apollo-server/src/index.ts index 61b3ce9210b..54d327a3e10 100644 --- a/packages/apollo-server/src/index.ts +++ b/packages/apollo-server/src/index.ts @@ -25,14 +25,17 @@ export interface ServerInfo { export class ApolloServer extends ApolloServerBase { private httpServer?: http.Server; private cors?: CorsOptions | boolean; + private onHealthCheck?: (req: express.Request) => Promise; constructor( config: ApolloServerExpressConfig & { cors?: CorsOptions | boolean; + onHealthCheck?: (req: express.Request) => Promise; }, ) { super(config); this.cors = config && config.cors; + this.onHealthCheck = config && config.onHealthCheck; } private createServerInfo( @@ -90,6 +93,7 @@ export class ApolloServer extends ApolloServerBase { app, path: '/', bodyParserConfig: { limit: '50mb' }, + onHealthCheck: this.onHealthCheck, cors: typeof this.cors !== 'undefined' ? this.cors