Sometimes it might be helpful to compare two GraphQL schemas with each other. For example, when working with multiple GraphQL APIs that each represent the same service but deployed to different development environments (e.g. dev, staging or prod). The graphql diff
command allows to quickly get an overview of the changes between two GraphQL schemas. They are compared via introspection queries.
Assume the following .graphqlconfig
:
projects:
hello-world:
extensions:
endpoints:
dev: https://myapiserver.com/graphql/dev
prod: https://myapiserver.com/graphql/prod
Example: Show the difference between the two GraphQL schemas on the dev
and prod
endpoints.
graphql diff --endpoint dev --target prod --project hello-world