New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

graphql-schema-diff

Package Overview
Dependencies
Maintainers
0
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

graphql-schema-diff

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

  • 3.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
0
Created
Source

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
    --input-value-deprecation    Include deprecated input value fields when loading from URL

  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);
  });

Keywords

FAQs

Package last updated on 18 Aug 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc