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 https://www.apollographql.com/docs/apollo-server/features/health-checks
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({
schema,
onHealthCheck: () => new Promise((resolve) => { console.log('hc called'); resolve() })
})
server
.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:
{server_address}:5000/.well-known/apollo/server-health
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