Example code that listens to a GraphOS custom check webhook to validate changes in query plans
The code that lives in api/webhook.ts
is example Typescript code for a Vercel Function that can be called by GraphOS Studio when a custom check is triggered.
This is an example in Vercel, but you could apply this code or logic to any runtime, serverless or not, you just need a public endpoint for GraphOS to call.
Inside the function we validate that it is a proper check notification with HMAC and then fetch the current and proposed supergraphs to check the differences in query plans.
As an example you could change the level of warnings vs errors in the _config-options.ts
file
- Clone the repo
- Install the latest LTS version of Node (see nvm)
- Install dependencies
npm install
- Start the app using the Vercel CLI locally:
npm run vercel
/api/hello
Simple test endpoint that returns a hello world message/api/webhook
Example Webhook that understands GraphOS Custom Checks