Migrating from GraphQL-CLI to Inspector CLI
GraphQL-CLI was wrapping the commands implemented in GraphQL-Inspector, in order to provide a unified experience. You can switch to using GraphQL-Inspector directly.
As such, it’s a good idea to start thinking about migrating to using graphql-inspector directly -
it is actively maintained and supported, and provides the same functionality as GraphQL-CLI with
some additional, new features.
Introduction
Today, GraphQL-CLI was wrapping the commands implemented in GraphQL-Inspector, in order to provide a unified experience. You can switch to using GraphQL-Inspector directly.
Migration Steps
The migration from GraphQL-CLI to Inspector CLI is relatively straightforward. Here are the steps you can take:
- Install Inspector CLI: You can install Inspector CLI using NPM by running the following command:
- Replace graphql-cli with graphql-inspector in your commands: After installing Inspector CLI, you’ll need to replace all instances of graphql in your commands with graphql-inspector.
For example, if you were previously using the following command to validate your schema with GraphQL-CLI:
You would now use the following command with Inspector CLI:
Examples
Here are examples of how to perform some common actions with both GraphQL-CLI and Inspector CLI:
Introspect
Validate
sh graphql validate './documents/*.graphql' http://localhost:3000/graphql
sh graphql-inspector validate './documents/\*.graphql' http://localhost:3000/graphql
Diff
sh graphql diff schema.graphql schema2.graphql sh graphql-inspector diff schema.graphql schema2.graphql Common
sh graphql common schema.graphql schema2.graphql sh graphql-inspector common schema.graphql schema2.graphql Coverage
sh graphql coverage schema.graphql --queries="queries/**/*.graphql" sh graphql-inspector coverage schema.graphql --queries "queries/**/*.graphql"
Similar
sh graphql similar schema.graphql schema2.graphql sh graphql-inspector similar schema.graphql schema2.graphql Conclusion
Migrating from GraphQL-CLI to Inspector CLI is a relatively simple process. By following the steps outlined in this post and updating your commands, you can continue to use a powerful and actively maintained tool for analyzing and manipulating GraphQL schemas.
Inspector CLI offers a number of useful actions, including common, coverage, diff, introspect, similar, and validate. With these actions, you can perform a wide range of tasks, from generating schemas to validating changes and analyzing coverage.
If you’re still using GraphQL-CLI and want to take advantage of the additional features and benefits offered by Inspector CLI, we highly recommend migrating as soon as possible. With Inspector CLI, you’ll have a more powerful and flexible tool for working with GraphQL schemas, and you’ll be better equipped to handle the evolving needs of your GraphQL workflow.