Setting the file. One moment.
Subchapter 12.3
references/graphs.mdMarkdown5 KBView on GitHub
Commands for managing monograph (non-federated) schemas in Apollo GraphOS.
Note: Use
rover subgraphcommands for federated graphs. Theserover graphcommands are for standalone GraphQL APIs without federation.
Download a graph schema from GraphOS.
# Basic fetch
rover graph fetch my-graph@production
# Output to file
rover graph fetch my-graph@production > schema.graphql
# JSON output
rover graph fetch my-graph@production --format jsonOptions:
| Option | Description |
|---|---|
--format <FORMAT> | Output format: plain (default) or json |
Extract schema from a running GraphQL server.
# Basic introspection
rover graph introspect http://localhost:4000/graphql
# With authentication header
rover graph introspect http://localhost:4000/graphql \
--header "Authorization: Bearer token123"
# Multiple headers
rover graph introspect http://localhost:4000/graphql \
--header "Authorization: Bearer token" \
--header "X-Tenant-ID: acme"
# Watch mode
rover graph introspect http://localhost:4000/graphql --watchOptions:
| Option | Description |
|---|---|
--header <HEADER> | HTTP header(s) to include |
--watch | Poll endpoint and output changes |
--polling-interval <SECONDS> | Interval for watch mode (default: 1) |
Publish a monograph schema to GraphOS.
# From file
rover graph publish my-graph@production \
--schema ./schema.graphql
# From stdin
cat schema.graphql | rover graph publish my-graph@production --schema -
# From introspection
rover graph publish my-graph@production \
--schema <(rover graph introspect http://localhost:4000/graphql)Options:
| Option | Description |
|---|---|
--schema <PATH> | Schema file path or - for stdin (required) |
Validate schema changes against GraphOS.
# Basic check
rover graph check my-graph@production \
--schema ./schema.graphql
# With validation thresholds
rover graph check my-graph@production \
--schema ./schema.graphql \
--query-count-threshold 100 \
--query-count-threshold-percentage 3Check validates:
Options:
| Option | Description |
|---|---|
--schema <PATH> | Schema file path (required) |
--query-count-threshold <N> | Min operations for breaking change |
--query-count-threshold-percentage <N> | Min % of operations |
--background | Run check in background |
Exit codes:
0 - Check passed1 - Check failed2 - Check completed with warningsRun GraphOS linting rules against a schema.
# Lint local schema (uses graph for rule configuration)
rover graph lint my-graph@production --schema ./schema.graphql
# Lint without graph reference
rover graph lint --schema ./schema.graphqlDelete a graph variant from GraphOS.
# Delete with confirmation
rover graph delete my-graph@staging
# Delete without confirmation
rover graph delete my-graph@staging --confirmWarning: This deletes the entire variant, not just the schema.
Options:
| Option | Description |
|---|---|
--confirm | Skip confirmation prompt |
| Aspect | rover graph | rover subgraph |
|---|---|---|
| Use case | Monographs | Federated subgraphs |
| Routing URL | Not required | Required for Router |
| Composition | N/A | Composes with other subgraphs |
--name flag | Not used | Required |
If migrating from a monograph to federation:
# 1. Fetch existing monograph schema
rover graph fetch my-graph@production > schema.graphql
# 2. Add federation directives to schema
# (edit schema.graphql to add @key, extend Query, etc.)
# 3. Publish as first subgraph
rover subgraph publish my-graph@production \
--name monolith \
--schema ./schema.graphql \
--routing-url https://api.example.com/graphql#!/bin/bash
set -e
GRAPH_REF="${APOLLO_GRAPH_REF:-my-graph@production}"
SCHEMA_PATH="./schema.graphql"
# Check schema changes
echo "Checking schema..."
rover graph check "$GRAPH_REF" --schema "$SCHEMA_PATH"
# Publish if check passes
echo "Publishing schema..."
rover graph publish "$GRAPH_REF" --schema "$SCHEMA_PATH"
echo "Schema published successfully!"