Last chance to speak on stage at GraphQL Summit! Submit your GraphQL Summit proposal by June 29. 🌴
Docs
Try Apollo Studio

Schema registration via the Rover CLI


If you're using a GraphQL server that doesn't support schema reporting, you can register your schema via the Rover CLI.

Do not use both schema reporting and Rover to register schemas for the same graph. Doing so can cause you to register "no-op" schema changes that are semantically identical but cosmetically different.

Registering a non-federated schema

  1. If you haven't yet:

  2. Decide how you'll provide your server's schema to Rover. You can either:

    • Use a .gql or .graphql file saved on your local machine, or
    • Perform an introspection query on your running server to fetch the schema
  3. Run the rover graph publish command, providing your schema in one of the ways shown:

    # Provide a local .graphql file path
    rover graph publish my-graph@my-variant --schema ./schema.graphql
    # Provide an introspection result via stdin
    rover graph introspect http://localhost:4000 | rover graph publish my-graph@my-variant --schema -

    As shown, the first positional argument you provide rover graph publish is a graph ref, a string that specifies a particular variant of a particular graph in Studio.

Registering federated schemas

See Setting up managed federation.

Registering with continuous delivery

To get the most out of Studio, you should register each update to your production schema as soon as it occurs. Consequently, schema registration should be part of your continuous delivery pipeline.

Here's a sample continuous delivery configuration for CLI-based schema registration using CircleCI:

version: 2
jobs:
build:
docker:
- image: circleci/node:8
steps:
- checkout
- run: npm install
- run:
name: Install Rover
command: |
# download and install Rover
curl -sSL https://rover.apollo.dev/nix/v0.3.0 | sh
# This allows the PATH changes to persist to the next `run` step
echo 'export PATH=$HOME/.rover/bin:$PATH' >> $BASH_ENV
# Start the GraphQL server. If a different command is used to
# start the server, use it in place of `npm start` here.
- run:
name: Starting server
command: npm start
background: true
# make sure the server has enough time to start up before running
# commands against it
- run: sleep 5
# When running on the 'main' branch, push the latest version
# of the schema to Apollo Studio.
- run: |
if [ "${CIRCLE_BRANCH}" == "main" ]; then
rover graph publish my-graph@my-variant --schema ./schema.graphql
fi
Edit on GitHub
Previous
Using schema reporting
Next
Protocol reference (advanced)