w3resource

The Apollo CLI


The Apollo CLI provides useful us with commands for interacting with every component of the Apollo platform, including Apollo Client, Apollo Server, and Apollo Graph Manager.

Download and install

Just like every other NodeJS module, the Apollo CLI is available as an npm package.

Project-level installation (recommended)

If your project uses npm, we recommend installing the Apollo CLI locally by adding it to your project's devDependencies, using this command:

npm install -D Apollo

This helps ensure that all of your project's collaborators have the same version of the CLI installed.

Global installation

You can install the CLI globally in your development environment with the following command:

npm install -g Apollo

Supported commands

Most of the Apollo CLI's commands are in the following namespaces:

  • client (such as apollo client:codegen) for interactions involving Apollo Client and Graph Manager
  • service (such as apollo service:check) for interactions involving Apollo Server and Graph Manager

For a full list of commands in a particular namespace, use the apollo help command:

Note: In the commands below, omit npx from the example commands below if you installed the Apollo CLI globally in your PC.

$ npx apollo help client

Check a client project against a pushed service

USAGE

$ apollo client:COMMAND

COMMANDS

client:check Check a client project against a pushed service
client:codegen Generate static types for GraphQL queries. Can use the published schema in Apollo Engine or a downloaded schema.
client:download-schema Download a schema from engine or a GraphQL endpoint.
client:extract Extract queries from a client
client:push Register operations with Apollo, adding them to the safelist

You can also obtain the full set of options for an individual command like so:

$ npx apollo help client:codegen

Previous: local state management
Next: Apollo extension for VS Code



Become a Patron!

Follow us on Facebook and Twitter for latest update.

It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.

https://w3resource.com/apollo-graphql/the-apollo-cli.php