Skip to content
📄🔄📄 Returns the diff of two GraphQL schemas. Detects dangerous and breaking changes.
TypeScript JavaScript
Branch: master
Clone or download
Pull request Compare This branch is 1 commit ahead, 12 commits behind fabsrc:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
@types/disparity
src
.gitignore
.travis.yml
LICENSE
README.md
npm-shrinkwrap.json
package.json
tsconfig.json

README.md

GraphQL Schema Diff

Build Status npm Dependencies Development Dependencies

Returns the diff of two GraphQL schemas. Detects dangerous and breaking changes.

Install

$ npm install -g graphql-schema-diff

Usage

$ graphql-schema-diff --help

  Returns the diff of two GraphQL schemas. Detects dangerous and breaking changes.

  Usage
    $ graphql-schema-diff <leftSchemaLocation> <rightSchemaLocation>

  Options
    --fail-on-dangerous-changes  Exit with error on dangerous changes
    --ignore-breaking-changes  Do not exit with error on breaking changes
    --create-html-output  Creates an HTML file containing the diff
    --html-output-directory  Directory where the HTML file should be stored (Default: './schemaDiff')
    --header, -H  Header to send to all remote schema sources
    --left-schema-header  Header to send to left remote schema source
    --right-schema-header Header to send to right remote schema source
    --sort-schema, -s Sort schemas prior to diffing

  Examples
    $ graphql-schema-diff https://example.com/graphql schema.graphql
    $ graphql-schema-diff https://example.com/graphql schema.graphql -H 'Authorization: Bearer 123'

Schema locations can be:

  • An URL to a GraphQL endpoint (e.g. https://swapi.graph.cool/)
  • A path to a single file (e.g. schemas/schema.graphql)
  • A glob pattern to merge multiple files (e.g. 'schemas/**/*.graphql')

API

Example

import { getDiff } from 'graphql-schema-diff';

const currentSchemaLocation = 'https://swapi.graph.cool/';
const newSchemaLocation = './schema.graphql';

getDiff(currentSchemaLocation, newSchemaLocation)
  .then((result) => {
    if (!result) {
      console.log('Schemas are identical!');
      return;
    }

    console.log(result.diff);
    console.log(result.diffNoColor);
    console.log(result.dangerousChanges);
    console.log(result.breakingChanges);
  });
You can’t perform that action at this time.