The Guild LogoThe Guild Monogram

Search docs

Search icon

Products by The Guild


Hive logoHive blurred logo


Schema Registry for your GraphQL Workflows

Skip to main content

Intercepting Schema Changes

GraphQL Inspector lets you intercept schema changes via HTTP. You're able to decide which changes are acceptable which are not and all of this through even a serverless function.

Whenever GraphQL Inspector runs schema checking triggered by Push or Pull Request events, your http endpoint receives a list of changes, list of related Pull Request or a commit SHA.



Configuring an interceptor looks fairly similar to endpoints, except you can't modify a method, it's always POST request.

Single environment setup:

# POST with no headersintercept: '<url>'schema: 'schema.graphql'
# With headersschema: 'schema.graphql'intercept:  url: '<url>'  headers:    auth: Basic <public-key>

Multiple environment setup:

schema: 'schema.graphql'# Or globbally# intercept: <url>env:  production:    branch: 'master'    intercept: '<url>'  development:    branch: 'develop'    intercept:      url: '<url>'      headers:        auth: Basic <public-key>

Setting an interceptor logic#

Let's set all criticality levels to Non-Breaking and GitHub Check conculsion to Success.

module.exports = (req, res) => {  const changes = req.body.changes;
  changes = changes.forEach((change) => {    change.criticality.level = 'NON_BREAKING';  });
  res.json({    changes,    conclusion: 'success',  });};

There's so much freedom here. Because you know which commit or a pull request triggered the check, you're able to decide if submitted changes should be rejected or accepted by fetching informations from GitHub API or your internal APIs.

Payload and Response structrues#


Described in TypeScript. Look at the source code to see the exact shape.

import {Change} from '@graphql-inspector/core';
interface DiffInterceptorPayload {  /**   * - see "pull_request"   */  pullRequests?: PullRequest[];  /**   * Commit SHA   */  ref?: string;  /**   *   */  changes: Change[];}


Described in TypeScript. Look at the source code to see the exact shape.

import {Change} from '@graphql-inspector/core';
interface DiffInterceptorResponse {  /**   *   */  conclusion?: CheckConclusion;  /**   *   */  changes: Change[];}