3 unstable releases

0.2.0 Jul 16, 2024
0.1.1 Feb 6, 2024
0.1.0 Jan 25, 2024

#1470 in Database interfaces

Download history 72/week @ 2024-08-14 122/week @ 2024-08-21 161/week @ 2024-08-28 171/week @ 2024-09-04 133/week @ 2024-09-11 140/week @ 2024-09-18 129/week @ 2024-09-25 118/week @ 2024-10-02 140/week @ 2024-10-09 106/week @ 2024-10-16 242/week @ 2024-10-23 80/week @ 2024-10-30 109/week @ 2024-11-06 531/week @ 2024-11-13 710/week @ 2024-11-20 571/week @ 2024-11-27

1,944 downloads per month

Apache-2.0

27KB
484 lines

graphql-schema-diff

crates.io] docs.rs

This crate implements diffing of two GraphQL schemas, returning a list of changes. It powers the changelog feature and operation checks at Grafbase.

Example

use graphql_schema_diff::{diff, Change, ChangeKind};

let source = r#"
  type Pizza {
    id: ID!
    name: String!
    toppings: [Topping!]!
  }

  enum Topping {
    OLIVES
    MUSHROOMS
    PINEAPPLE
  }
"#;

let target = r#"
  type Pizza {
    id: ID!
    name: PizzaName
    toppings: [Topping!]!
  }

  type PizzaName {
    english: String
    italian: String!
  }

  enum Topping {
    OLIVES
    MUSHROOMS
    POTATO
  }
"#;

let changes = diff(source, target).unwrap();

assert_eq!(changes,
   &[
        Change {
            path: String::from("Pizza.name"),
            kind: ChangeKind::ChangeFieldType
        },
        Change {
            path: String::from("PizzaName"),
            kind: ChangeKind::AddObjectType
        },
        Change {
            path: String::from("Topping.PINEAPPLE"),
            kind: ChangeKind::RemoveEnumValue
        },
        Change {
            path: String::from("Topping.POTATO"),
            kind: ChangeKind::AddEnumValue
        }
]);

Cargo features

  • serde: Serialize and Deserialize impls for Change (default: on).

Dependencies

~4.5MB
~69K SLoC