Documentation
Migration Guides
From GraphQL-CLI

Migrating from GraphQL-CLI to Inspector CLI

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.

⚠️
The package @graphql-cli is deprecated, and no longer maintained!

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:

  1. Install Inspector CLI: You can install Inspector CLI using NPM by running the following command:
npm i --global @graphql-inspector/cli graphql
  1. 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:

graphql validate './documents/*.graphql' http://localhost:3000/graphql

You would now use the following command with Inspector CLI:

graphql-inspector validate './documents/*.graphql' http://localhost:3000/graphql

Examples

Here are examples of how to perform some common actions with both GraphQL-CLI and Inspector CLI:

Introspect

graphql get-schema --endpoint=https://api.example.com/graphql --header="Authorization: Bearer YOUR_TOKEN" > schema.graphql

Validate

graphql validate './documents/*.graphql' http://localhost:3000/graphql

Diff

graphql diff schema.graphql schema2.graphql

Common

graphql common schema.graphql schema2.graphql

Coverage

graphql coverage schema.graphql --queries="queries/**/*.graphql"

Similar

graphql 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.