https://github.com/fabsrc/graphql-schema-diff
:page_facing_up::arrows_counterclockwise::page_facing_up: Returns the diff of two GraphQL schemas. Detects dangerous and breaking changes.
https://github.com/fabsrc/graphql-schema-diff
breaking-changes dangerous-changes diff graphql graphql-schema hacktoberfest schema
Last synced: about 2 months ago
JSON representation
:page_facing_up::arrows_counterclockwise::page_facing_up: Returns the diff of two GraphQL schemas. Detects dangerous and breaking changes.
- Host: GitHub
- URL: https://github.com/fabsrc/graphql-schema-diff
- Owner: fabsrc
- License: mit
- Created: 2019-02-06T21:52:22.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2024-11-18T20:54:01.000Z (6 months ago)
- Last Synced: 2025-03-28T07:02:03.708Z (about 2 months ago)
- Topics: breaking-changes, dangerous-changes, diff, graphql, graphql-schema, hacktoberfest, schema
- Language: TypeScript
- Homepage:
- Size: 1.22 MB
- Stars: 69
- Watchers: 2
- Forks: 9
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# GraphQL Schema Diff
[](https://github.com/fabsrc/graphql-schema-diff/actions/workflows/main.yml)
[](https://www.npmjs.com/package/graphql-schema-diff)Returns the diff of two GraphQL schemas. Detects dangerous and breaking changes.
## Install
```sh
$ npm install -g graphql-schema-diff
```## Usage
```sh
$ graphql-schema-diff --helpReturns the diff of two GraphQL schemas. Detects dangerous and breaking changes.
Usage
$ graphql-schema-diffOptions
--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
--input-value-deprecation Include deprecated input value fields when loading from URLExamples
$ 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
```js
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
* [GraphQL Inspector](https://github.com/kamilkisiela/graphql-inspector) ouputs a list of changes between two GraphQL schemas.
* [GraphQL Tools](https://github.com/ardatan/graphql-tools) provides a set of utils for faster development of GraphQL tools.