All skills
apollographql avatar

/apollo-router

@f13ff34 official
by Apollo GraphQLapollographql/skills115 stars
13

Version-aware guide for configuring and running Apollo Router for federated GraphQL supergraphs. Generates correct YAML for both Router v1.x and v2.x. Use this skill when: (1) setting up Apollo Router to run a supergraph, (2) configuring routing, headers, or CORS, (3) implementing custom plugins (Rhai scripts or coprocessors), (4) configuring telemetry (tracing, metrics, logging), (5) troubleshooting Router performance or connectivity issues, (6) securing the graph with JWT, declarative field-level authorization directives, or persisted-query safelisting, (7) managing router.yaml as version-controlled config with CI/CD validation.

Use this Skill: https://skilld.dev/gh/apollographql/skills/apollo-router

This session only. Nothing lands on disk.

referencestroubleshooting.md

≈1.9k tokens on demand. Your agent reads this file only when SKILL.md points to it.

Router Troubleshooting

Common issues and solutions when running Apollo Router.

Startup Issues

Router Fails to Start

Error: No supergraph schema provided

Error: No supergraph schema found. Provide --supergraph or set APOLLO_GRAPH_REF.

Fix: Provide a supergraph schema:

# Local file
router --supergraph ./supergraph.graphql

# Or GraphOS managed
export APOLLO_KEY=service:my-graph:key
export APOLLO_GRAPH_REF=my-graph@production
router

Error: Invalid configuration

Error: configuration error: unknown field `cors`

Fix: Check YAML syntax and field names:

# Validate config
router config validate router.yaml

Port Already in Use

Error: Address already in use (os error 48)

Fix: Use a different port or stop the existing process:

# Check what's using the port
lsof -i :4000

# Use different port
router --supergraph ./supergraph.graphql --listen 127.0.0.1:4001

Connection Issues

Cannot Connect to Subgraphs

Error: Connection refused

Error: error sending request for url (http://localhost:4001/graphql): error trying to connect

Checklist:

  1. Verify subgraph is running: curl -X POST http://localhost:4001/graphql -H "Content-Type: application/json" -d '{"query":"{ __typename }"}'
  2. Check URL in supergraph schema is correct
  3. For Docker, use host.docker.internal or service names

Override subgraph URL for local development:

# router.yaml
override_subgraph_url:
  products: http://host.docker.internal:4001/graphql

Error: Timeout

Error: operation timed out

Increase timeout:

traffic_shaping:
  subgraphs:
    slow-service:
      timeout: 60s

GraphOS Connection Issues

Error: Failed to fetch schema from Uplink

Error: failed to fetch schema: Uplink request failed

Checklist:

  1. Verify APOLLO_KEY is correct
  2. Verify APOLLO_GRAPH_REF format: graph-id@variant
  3. Check network connectivity to Apollo
# Test connection
curl -H "X-Api-Key: $APOLLO_KEY" \
  https://uplink.api.apollographql.com/

Query Issues

Introspection Not Working

Error: Introspection disabled

{
  "errors": [{ "message": "Introspection has been disabled" }]
}

Fix: Enable introspection (development only):

supergraph:
  introspection: true

Or use --dev mode:

router --dev --supergraph ./supergraph.graphql

Sandbox Not Loading

Sandbox requires introspection. Enable both:

supergraph:
  introspection: true

sandbox:
  enabled: true

Or use --dev mode which enables both.

CORS Errors

Error: Browser blocked by CORS policy

Access to fetch has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header

Fix: Configure CORS using the correct schema for your Router version:

v1 (flat schema):

cors:
  origins:
    - http://localhost:3000
    - https://studio.apollographql.com
  allow_headers:
    - Content-Type
    - Authorization

v2 (policies schema):

cors:
  max_age: 24h
  policies:
    - origins:
        - http://localhost:3000
        - https://studio.apollographql.com
      allow_headers:
        - Content-Type
        - Authorization

For development (not production):

# v1
cors:
  origins:
    - "*"

# v2
cors:
  allow_any_origin: true

CORS config ignored after upgrading to v2: If you upgraded from v1 to v2 and your CORS settings stopped working, you're likely using the v1 flat schema (cors.origins). v2 requires the policies array format (cors.policies). See the divergence map for the full diff. You can auto-migrate with: router config upgrade router.yaml

JWT Issuer Field Mismatch (v2)

If you migrated from v1 to v2 and kept the singular issuer field instead of the plural issuers array, the config uses a v1-only field. Use issuers for Router v2.

Broken (v1 field in v2 config):

authentication:
  router:
    jwt:
      jwks:
        - url: https://auth.example.com/.well-known/jwks.json
          issuer: https://auth.example.com/   # WRONG for v2!

Fixed (v2 field):

authentication:
  router:
    jwt:
      jwks:
        - url: https://auth.example.com/.well-known/jwks.json
          issuers:                              # Correct for v2
            - https://auth.example.com/

Performance Issues

Slow Queries

Debug steps:

  1. Enable query plan logs:
telemetry:
  exporters:
    logging:
      stdout:
        enabled: true
        format: json
  1. Check subgraph latency: Enable tracing to identify slow subgraphs.

  2. Enable caching:

supergraph:
  query_planning:
    cache:
      in_memory:
        limit: 512

High Memory Usage

  1. Limit cache sizes:
supergraph:
  query_planning:
    cache:
      in_memory:
        limit: 256  # Reduce from default
  1. Check for complex queries that generate large query plans.

Response Cache Misses

  1. Check subgraph Cache-Control headers: origin must return Cache-Control without no-store
  2. Verify Cache-Control headers: subgraph responses need Cache-Control: max-age=N (via @cacheControl in Apollo Server, or set directly in other frameworks)
  3. Check scope: Cache-Control: private requires private_id to be configured on the router
  4. Verify Redis connectivity: check apollo.router.cache.redis.errors metric
  5. Enable cache debugger (dev only): set response_cache.debug: true and use Apollo Sandbox to inspect cache state

Federation Issues

Composition Errors at Runtime

Router logs composition errors:

Error: Subgraph schema validation failed

Fix: Validate schema before deploying:

rover subgraph check my-graph@production \
  --name products \
  --schema ./schema.graphql

Entity Resolution Failures

Error: Cannot resolve entity

{
  "errors": [{ "message": "cannot resolve entity of type User" }]
}

Checklist:

  1. Subgraph implements _entities query
  2. Entity's @key fields match between subgraphs
  3. Reference resolver returns correct data format

Health Check

Check Router health on the configured health listener (the provided templates use 127.0.0.1:8088/health):

curl http://localhost:8088/health

Expected response:

{"status":"healthy"}

If you are not using an explicit health_check config, Router also exposes:

curl http://localhost:4000/.well-known/apollo/server-health

For Kubernetes readiness probe (matching this skill's templates):

readinessProbe:
  httpGet:
    path: /health
    port: 8088
  initialDelaySeconds: 5
  periodSeconds: 10

Debug Mode

Get more verbose output:

APOLLO_ROUTER_LOG=debug router --supergraph ./supergraph.graphql

Log levels:

  • error - Errors only
  • warn - Warnings and errors
  • info - General information (default)
  • debug - Detailed debug information
  • trace - Very verbose tracing

Common Mistakes

Mistake Solution
Introspection disabled in dev Use --dev flag
Wrong subgraph URL in production Use override_subgraph_url
CORS not configured Add allowed origins
Timeout too short Increase traffic_shaping.timeout
Missing APOLLO_KEY Set environment variable
Wrong graph ref format Use graph-id@variant

Getting Help

  1. Check Router documentation
  2. Search Apollo Community
  3. Check GitHub Issues
  4. Enable debug logging for detailed error information

Source: SKILL.md on GitHub

2 warnings16d5 checks · Risk SAFE
  • Gen Agent Trust Hub16d

    The skill is a configuration generator and guide for Apollo Router. It implements robust security best practices by default, including environment variable interpolation for sensitive data, disabling developmental features (introspection/sandbox) in production, and providing a validation checklist. No malicious patterns, data exfiltration, or unauthorized command execution risks were found.

  • Socket16d

    1 alert: gptAnomaly

  • Snyk16d

    Risk: LOW · No issues

  • Runlayer7mo

    26/26 files flagged

  • ZeroLeaks5mo

    Score: 93/100 · 2 sections analyzed

Signed by skilld at f13ff34. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub yesterday.

Activeupdated 4 months ago
What it can do
Runs commands
metadata
{
  "author": "apollographql",
  "version": "2.5.0"
}
All 1 allowed tools
Bash(router:*) Bash(./router:*) Bash(rover:*) Bash(curl:*) Bash(docker:*) Read Write Edit Glob Grep
Other metadata
compatibility
Linux/macOS/Windows. Requires a composed supergraph schema from Rover or GraphOS.
  • apollo-router
  • graphql
  • federation
  • routing
  • yaml
  • telemetry
  • authentication
  • cors

README badge

README badge for apollographql/skills/apollo-router

Generates version-aware Apollo Router configuration (v1.x or v2.x) for federated GraphQL supergraphs, handling routing, authentication, CORS, telemetry, and connectors. Use this skill to set up Router with JWT auth, traffic shaping, operation limits, or to troubleshoot connectivity and performance issues.

Generated from the current SKILL.md.

Does this skill support both Router v1 and v2?
Yes. The skill generates version-correct YAML for both v1.x and v2.x, which have incompatible config schemas. You must select your target version before generating any config.
Can I use this skill to configure Connectors?
Yes, but only for Router v2. Connectors (REST API integration) are a v2-only feature available in GA. The skill will not offer Connectors as an option if you select v1.
What do I need before I can run the generated config?
You need either a composed `supergraph.graphql` file from Rover or GraphOS access via `APOLLO_KEY` and `APOLLO_GRAPH_REF`. The skill assumes you have reachable subgraphs and will validate the config against the Router binary if available.
Does this skill help with response caching?
Yes, but only for Router v2.6.0 and later. The skill requires you to identify which subgraphs serve user-specific data and how you identify users before generating cache config, to prevent data leakage.
Will the skill validate my generated config?
Yes. After generating or editing config, the skill runs a checklist and attempts to validate against `router config validate` if the Router CLI is available. It will report pass/fail for each checklist item.

Generated from the current SKILL.md. These answers refresh after source changes.