Setting the file. One moment.
Subchapter 12.2
references/dev.mdMarkdown6 KBView on GitHub
Run a local supergraph for development with automatic schema composition and hot reloading.
# Start with supergraph config
rover dev --supergraph-config supergraph.yaml
# Start on specific port
rover dev --supergraph-config supergraph.yaml --router-port 4000Default behavior:
http://localhost:4000http://localhost:4000http://localhost:4000/healthCreate supergraph.yaml for local development:
federation_version: =2.9.0
subgraphs:
products:
routing_url: http://localhost:4001/graphql
schema:
file: ./products/schema.graphql
reviews:
routing_url: http://localhost:4002/graphql
schema:
subgraph_url: http://localhost:4002/graphql
users:
routing_url: http://localhost:4003/graphql
schema:
file: ./users/schema.graphqlWhen using schema.file, Rover watches for file changes:
subgraphs:
products:
schema:
file: ./products/schema.graphql # Watched for changesSave the file and Rover automatically recomposes.
When using schema.subgraph_url, Rover polls for changes:
subgraphs:
reviews:
schema:
subgraph_url: http://localhost:4002/graphql # Polled for changesStart with a GraphOS variant as baseline and override locally:
rover dev --graph-ref my-graph@staging --supergraph-config local-overrides.yamllocal-overrides.yaml:
federation_version: =2.9.0
subgraphs:
# Override products with local version
products:
routing_url: http://localhost:4001/graphql
schema:
file: ./products/schema.graphql
# Other subgraphs come from GraphOS variantrover dev \
--supergraph-config supergraph.yaml \
--router-config router.yamlrouter.yaml:
supergraph:
listen: 127.0.0.1:4000
headers:
all:
request:
- propagate:
matching: "^x-.*"
cors:
origins:
- http://localhost:3000
allow_headers:
- Content-Type
- Authorization
telemetry:
apollo:
endpoint: https://usage.api.apollographql.com/api/ingress/traces# Sandbox enabled (default in dev)
sandbox:
enabled: true
# Introspection enabled (default in dev)
introspection: true
# Query plans in response
include_subgraph_errors:
all: trueEnable MCP server alongside Router:
rover dev --supergraph-config supergraph.yaml --mcpMCP options:
# Specify MCP port
rover dev --supergraph-config supergraph.yaml --mcp --mcp-port 5001
# MCP output format
rover dev --supergraph-config supergraph.yaml --mcp --mcp-format jsonUse cases:
# Terminal 1: Products subgraph
cd products && npm run dev # Runs on 4001
# Terminal 2: Reviews subgraph
cd reviews && npm run dev # Runs on 4002
# Terminal 3: Rover dev
rover dev --supergraph-config supergraph.yamlsupergraph.yaml:subgraphs:
# existing...
new-service:
routing_url: http://localhost:4004/graphql
schema:
file: ./new-service/schema.graphql| Option | Description | Default |
|---|---|---|
--supergraph-config <PATH> | Path to supergraph config | Required |
--graph-ref <REF> | GraphOS variant for baseline | None |
--router-port <PORT> | Router listen port | 4000 |
--router-config <PATH> | Custom Router config | None |
--mcp | Enable MCP server | false |
--mcp-port <PORT> | MCP server port | 5001 |
--log <LEVEL> | Log level | info |
# Check what's using port 4000
lsof -i :4000
# Use different port
rover dev --supergraph-config supergraph.yaml --router-port 4001Error: Could not connect to subgraph "products" at http://localhost:4001/graphql# Check composition separately
rover supergraph compose --config supergraph.yaml
# Look for specific errors in outputFor file-based schemas:
For introspection:
# Required for GraphOS features
export APOLLO_KEY=your-api-key
export APOLLO_GRAPH_REF=my-graph@staging
# Run with environment
APOLLO_KEY=$APOLLO_KEY rover dev \
--graph-ref $APOLLO_GRAPH_REF \
--supergraph-config local.yaml# 1. Start subgraph servers
npm run dev:subgraphs # Custom script to start all
# 2. Start Rover dev
rover dev --supergraph-config supergraph.yaml
# 3. Open http://localhost:4000 for Sandbox
# 4. Make schema changes - auto-reloads
# 5. Ctrl+C to stop# docker-compose.yaml
services:
products:
build: ./products
ports:
- "4001:4001"
reviews:
build: ./reviews
ports:
- "4002:4002"# Start services
docker-compose up -d
# Start Rover dev
rover dev --supergraph-config supergraph.yaml