Apollo Server Health Check Not Getting Called

This is a basic issue which I followed the documentation and it is not working as expected, please shed some light.

So, I am creating a grapqhl server with Apollo-Server and trying to get the health-check url working that is given here

Here is the code:

const { ApolloServer, makeExecutableSchema } = require('apollo-server')

const typeDefs = require('./schema/types/')
const resolvers = require('./schema/resolvers/')
const schema = makeExecutableSchema({ typeDefs, resolvers })
const server = new ApolloServer({
  onHealthCheck: () => new Promise((resolve) => { console.log('hc called'); resolve() })
  .listen({ port: 5000 })
  .then(({ url }) => console.log(`🚀  Server ready at ${url}`))
  .catch(() => console.log('error'))

As I start the server I get this log:

🚀  Server ready at http://localhost:5000/

And also, I am able to see the Schema in graphql-playground as well, which means my typeDefs and resolvers are fine, but when I ping the url:


I am getting the output as:

   "status": "pass"

Without any log saying: hc called which I added in the code for key named 'onHealthCheck' and for now I resolved it as well, as per the docs.

So where is the problem and what I missed, please shed some light. Happy coding :)

PS: I am using apollo-server 2.5.0 version which I think very recently updated with onHealthCheck fix for onHealthCheck not getting called



The fix was just merged into master 6 days ago. You need to update to a later version, like 2.6.0-alpha.8.