Skip to content

Repository with a sample applications for implementing a GraphOS Schema Check webhook integration

License

Notifications You must be signed in to change notification settings

apollosolutions/custom-check-examples

Repository files navigation

Custom schema check webhook examples

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.

Example graphql-eslint implementation

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.

Installation

  1. Set up a Netlify account, then install and authenticate with Netlify CLI.
  2. Install dependencies and build function code. $ npm install ; npm run build
  3. 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 the dist/ to upload the built function.
  4. Pull up site you created in the Netlify web console.
  5. In the Netlify console, go to Site configuration > Environment variables. Add and upload values for the environment variables: APOLLO_HMAC_TOKEN and APOLLO_API_KEY.
    • The APOLLO_HMAC_TOKEN should be any string that will be used to calculate the x-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.
  6. Deploy the function to production. $ netlify deploy --prod
  7. From your terminal, copy the Website URL plus the path /custom-lint and go to GraphOS Studio.
  8. 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.
  9. 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.

About

Repository with a sample applications for implementing a GraphOS Schema Check webhook integration

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published