This repository contains a sample validation service for GraphOS custom schema check.
Note
The code in this repository is experimental and has been provided for reference purposes only. This repository may not be supported in the same way that repositories in the official Apollo GraphQL GitHub organization are. If you need help, you can file an issue on this repository, contact Apollo Support, or create a ticket directly in GraphOS Studio.
This example implementation deploys a Netlify function that can be used to set up a webhook integration with GraphOS schema checks.
This example Netlify function does the following:
- Receives the webhook payload from GraphOS.
- Validates the HMAC value in the
x-apollo-signature
header. - Downloads the composed supergraph.
- Lints the schema using graphql-eslint.
- Uploads any linter violations back to GraphOS to complete the custom check task.
After building and deploying the function, you need to enable custom schema checks and register the function endpoint in GraphOS Studio.
- Set up a Netlify account, then install and authenticate with Netlify CLI.
- Install dependencies and build function code.
$ npm install ; npm run build
- To deploy to Netlify, follow the CLI instructions for creating and configuring a new site.
$ netlify deploy
- When asked for the publish directory, use the default root directory. The
netlify.toml
file has a pointer to thedist/
to upload the built function.
- When asked for the publish directory, use the default root directory. The
- Pull up site you created in the Netlify web console.
- In the Netlify console, go to Site configuration > Environment variables. Add and upload values for the environment variables:
APOLLO_HMAC_TOKEN
andAPOLLO_API_KEY
.- The
APOLLO_HMAC_TOKEN
should be any string that will be used to calculate thex-apollo-signature header
. - The
APOLLO_API_KEY
is a GraphOS API key with sufficient permissions to run schema checks for the graph you're integrating this application with.
- The
- Deploy the function to production.
$ netlify deploy --prod
- From your terminal, copy the Website URL plus the path
/custom-lint
and go to GraphOS Studio. - In the graph you're integrating this with go to Checks > Configuration and enable custom checks, registering the function URL and entering your
APOLLO_HMAC_TOKEN
as the secret token. - Run a schema check using the Rover CLI to test the integration.
- You should see check results in GraphOS Studio on the Checks page. You can also verify logs in the Netlify console.