paul590
paul590

Reputation: 1425

Apollo Server Health Check custom response

I am currently looking to provide more information to the health check other than status: pass. Is this possible? I tried sending test strings unfortunately, I am still seeing the same response json. Thank you in advance!

Code:

       onHealthCheck: (req) => {
            return new Promise((resolve, reject) => {
                if(true) {
                    console.log(req);
                    resolve(req);
                    //resolve("test")
                } else {
                    reject();
                }
            })
        }

Upvotes: 0

Views: 1203

Answers (1)

hp10
hp10

Reputation: 632

onHealthCheck implementation looks like this (express is used):

    if (onHealthCheck) {
      onHealthCheck(req)
        .then(() => {
          res.json({ status: 'pass' });
        })
        .catch(() => {
          res.status(503).json({ status: 'fail' });
        });
    }

so as you can see, it returns hardcoded value.

You can always implement your custom health check also using express.

Upvotes: 1

Related Questions