2.8.2 • Published 4 months ago

graphql-schema-diff v2.8.2

Weekly downloads
1,292
License
MIT
Repository
github
Last release
4 months ago

GraphQL Schema Diff

Build Status npm

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
    --fail-on-breaking-changes   Exit with error on breaking changes
    --fail-on-all-changes        Exit with error on all 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-graphql.netlify.app/.netlify/functions/index';
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);
  });

Related Packages

2.8.2

4 months ago

2.7.0

11 months ago

2.6.1

11 months ago

2.8.1

9 months ago

2.8.0

9 months ago

2.6.0

1 year ago

2.5.1

1 year ago

2.5.0

2 years ago

2.4.0

3 years ago

2.3.0

3 years ago

2.2.0

4 years ago

2.1.0

4 years ago

2.0.0

4 years ago

1.0.0

4 years ago

0.6.3

5 years ago

0.6.2

5 years ago

0.6.1

5 years ago

0.6.0

5 years ago

0.5.2

5 years ago

0.5.1

5 years ago

0.5.0

5 years ago

0.4.0

5 years ago

0.3.0

5 years ago

0.2.0

5 years ago

0.1.3

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago