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 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
Answer
The fix was just merged into master 6 days ago. You need to update to a later version, like 2.6.0-alpha.8
.
Related Questions
- → Maximum call stack exceeded when instantiating class inside of a module
- → Browserify api: how to pass advanced option to script
- → Node.js Passing object from server.js to external modules?
- → gulp-rename makes copies, but does not replace
- → requiring RX.js in node.js
- → Remove an ObjectId from an array of objectId
- → Can not connect to Redis
- → React: How to publish page on server using React-starter-kit
- → Express - better pattern for passing data between middleware functions
- → Can't get plotly + node.js to stream data coming through POST requests
- → IsGenerator implementation
- → Async/Await not waiting
- → (Socket.io on nodejs) Updating div with mysql data stops without showing error