The Apollo CLI
⚠️ Important: All
apollo service:* commands are now deprecated in favor of commands in the Rover CLI.
The Apollo CLI provides useful commands for interacting with every component of the Apollo platform, including Apollo Client, Apollo Server, and GraphOS Studio.
The Apollo CLI is available as an npm package.
If your project uses
npm, we recommend installing the Apollo CLI locally by adding it to your project's
devDependencies, like so:
npm install -D apollo
This helps make sure that all of your project's collaborators have the same version of the CLI installed.
You can install the CLI globally in your development environment with the following command:
npm install -g apollo
Like all other tools, the Apollo CLI requires an API key to communicate with GraphOS Studio. For each of your projects, obtain a graph API key for the project's associated graph, and set that key as the value of
APOLLO_KEY in your application's
Alternatively, you can provide an API key to individual CLI commands with the
apollo client:check --graph=MyGraph --key=service:docs-example-graph:NYKgCqwfCyYPIm84WVXCdw
Most of the Apollo CLI's commands are in the following namespaces:
apollo client:codegen) for interactions involving Apollo Client and GraphOS Studio
apollo service:check) for interactions involving Apollo Server and GraphOS Studio
- ⚠️ Important: All
apollo service:*commands are now deprecated in favor of commands in the Rover CLI.
- ⚠️ Important: All
For a full list of commands in a particular namespace, use the
apollo help command:
npx from the example commands below if you installed the Apollo CLI globally.
$ npx apollo help clientCheck a client project against a pushed serviceUSAGE$ apollo client:COMMANDCOMMANDSclient:check Check a client project against a pushed serviceclient:codegen Generate static types for GraphQL queries. Can use thepublished schema in the Apollo registry or adownloaded schema.client:download-schema Download a schema from Apollo or a GraphQL endpoint inJSON or SDL formatclient:extract Extract queries from a clientclient:push Register operations with Apollo, adding them to thesafelist
You can also obtain the full set of options for an individual command like so:
$ npx apollo help client:codegen