Skip to content

Latest commit

 

History

History
45 lines (40 loc) · 1.08 KB

File metadata and controls

45 lines (40 loc) · 1.08 KB

graphql-query-compare

Extension library for graphql-java to compare GraphQL queries and check them for equality. This is useful for testing purposes if you want to assert the GraphQL queries your application is making.

You can compare the queries on multiple levels:

  • Document level
  • Selection set
  • Fields
  • Arguments
  • Values

Usage:

Document firstDocument = parser.parseDocument(readQuery("equalquerywithdifferentorderoffields/query1.graphql"));
Document secondDocument = parser.parseDocument(readQuery("equalquerywithdifferentorderoffields/query2.graphql"));

DocumentCompare.isEqual(firstDocument, secondDocument);

So the following queries are considered equal:

query Query {
    vehicle(licenseplate: "AABBCC25", identification: "aaBBccDD1234") {
      brand
      year
      owner {
        firstName
        lastName
     }
  }
}
query Query {
vehicle(identification: "aaBBccDD1234", licenseplate: "AABBCC25") {
      owner {
        lastName
        firstName
     }
      year
      brand
  }
}