Introducing: GraphQL Inspector
Prevent breaking changes. Find broken operations. Get Schema Coverage. Check deprecated usage and type duplicates. All as part of your CI process
Throughout almost three years of working with GraphQL, me and The Guild introduced solutions that changed the way we write our projects today.
In order to use GraphQL in our Angular applications, we created Angular Apollo. To automate and increase type-safety, we open-sourced GraphQL Code Generator. Most recent thing was GraphQL Modules that helped us to separate a server into smaller, reusable, feature based parts. All of that was developed based on the experience and used with huge success by our clients.
Today, I’m happy to introduce another piece of our tech stack, we call it
GraphQL inspector is a tool that’s main purpose is to make sure your GraphQL API and all its clients are well developed.
- Finds breaking, dangerous and safe changes when modifying a GraphQL API
- Github Application + Github Action (Bitbucket integration soon)
- Command Line Interface
- Completely free and open-source — host your own GraphQL Inspector
- Schema coverage —see unused parts of Schema based on all your clients’ fragments and operations
- Validates operations against a GraphQL Schema — you notice errors before run-time!
- Finds duplicates or similar types
Use it in Github
We offer GraphQL Inspector as a Github Application that you can install in any of your repositories within a single click. That’s the easiest way possible to start using Inspector.
Inspector as part of your workflow
In order to use GraphQL Inspector, you need to make sure you write an entire GraphQL Schema to a file so Inspector could see it. Git hooks fits well here. Whenever there’s a new commit, the file will be updated.
Next, you configure GraphQL Inspector in
You can read more about that in “Github Application” chapter on our website.
Now, whenever someone submits a Pull Request the GraphQL Inspector will compare schemas and fail if there are breaking changes.
I know Github Actions are not yet publicly available but if you’re lucky enough, you can use them to host your own GraphQL Inspector that is deployed and live per each commit or a pull request. Because an Action is temporarily executed with Docker, you won’t use any Cloud service or any other paid resources.
Right now, Actions are not the most enjoyable thing but because it’s free and super easy to setup we highly recommend to take advantage of it if you don’t want to use hosted by us GraphQL Inspector.
We don’t store any data, the code is open-sourced and deployed with Netlify Functions.
Because we strongly believe in open-source, you can also have your own instance of GraphQL Inspector up and running.
GraphQL Inspector doesn’t support Bitbucket yet but it’s on top of our roadmap and we’re starting working on it. If you need it, please reach out or comment on the open issue.
Prevent breaking changes
GraphQL Inspector compares an old and a new GraphQL Schema in order to alert you about breaking changes. It also tracks other changes, dangerous to implement and those that are entirely safe.
This way you have a clear vision of how your Schema is developed.
The idea behind it is to see which part of your schema is used, how many times and by which operation. It only applies to documents that can be statically analyzed.
Validate documents and find deprecated usage
In order to find out that your operation or fragment is broken you need to run an app and execute a query or mutation. Thanks to GraphQL Inspector, you can easily check for errors or deprecated usage at any point of time.
I recommend to make it as part of your CI or even git hooks.
Another interesting feature of Inspector allows you to find similar types and maybe even duplicates. It’s not something everyone might want to use but we found it really helpful when we were migrating few separate GraphQL APIs to a monorepo and merging them into a single server at Air France — KLM. The person who could say more about that would be Mart Ganzevles, who’s the father of that particular feature and it was his first ever open-source contribution. Amazing work Mart!
We are going to work on a Desktop version of GraphQL Inspector to boost the whole experience even further. Imagine exploring everything in a nicely done and interactive application. You could click on things in order to see them in details, just amazing!
- Runs a GraphQL Server with faked data within a single command
- Writes an introspection result of GraphQL Schema to a file
How does it compare to other tools
GraphQL Inspector tries to solve a bit of a different use-case. The main idea behind Apollo Engine is to get insights of how a GraphQL server behaves in production.
It supports schema comparison too but the main difference is that we don’t store any of your data and in order to track changes, we simply take advantage of Git. Each change is available in git history, so the workflow is straightforward and it’s something you’re already familiar with.
Because of that, Apollo’s advantage is that it takes into account production data and not only your code. But if that is important to you, you can gather this data from your GraphQL servers today, store it wherever you want, and we can add a feature to add this data into one of our reports.
GraphQL Doctor and our tool have in common only the Schema Comparison feature, but Inspector tracks also changes that are safe to introduce. Doctor’s main goal is to run within Github and prevent from breaking an API. We would love to collaborate with them, make sure we truly covered all their use cases and maybe merge their library into ours.
In The Guild, we love open-source, our whole careers were possible because of that. We also found out each other through Open-Source :)
That’s why I encourage you to help us develop GraphQL Inspector and let’s build it together.
Smallest piece of code, bug fix, documentation improvement or even a simplest suggestion counts as contribution!
- Website and documentation
- Visit the repository on Github
- CLI available —
$ yarn global add @graphql-inspector/cli
- Checkout the Github Application
- See an example app that uses GraphQL Inspector