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
If you haven't yet:
- Install the Rover CLI
- Authenticate Rover with Apollo Studio
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
- Use a
Run the
rover graph publish
command, providing your schema in one of the ways shown:# Provide a local .graphql file pathrover graph publish my-graph@my-variant --schema ./schema.graphql# Provide an introspection result via stdinrover 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: 2jobs:build:docker:- image: circleci/node:8steps:- checkout- run: npm install- run:name: Install Rovercommand: |# download and install Rovercurl -sSL https://rover.apollo.dev/nix/v0.3.0 | sh# This allows the PATH changes to persist to the next `run` stepecho '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 servercommand: npm startbackground: 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" ]; thenrover graph publish my-graph@my-variant --schema ./schema.graphqlfi