graphql-schema-diff

Crates.iographql-schema-diff
lib.rsgraphql-schema-diff
version0.2.0
sourcesrc
created_at2024-01-25 08:37:57.892073
updated_at2024-07-16 07:03:38.247538
descriptionSemantic diffing for GraphQL schemas
homepagehttps://grafbase.com
repositoryhttps://github.com/grafbase/grafbase/tree/main/engine/crates/graphql-schema-diff
max_upload_size
id1113561
size40,997
Tom Houlé (tomhoule)

documentation

README

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).
Commit count: 6427

cargo fmt