apollo-router

작성자: apollographql

Apollo Router는 Apollo Federation 2 슈퍼그래프를 실행하기 위해 Rust로 작성된 고성능 그래프 라우터입니다. 서브그래프 앞에 위치하여 쿼리 계획, 실행 및 응답 구성을 처리합니다.

npx skills add https://github.com/apollographql/skills --skill apollo-router

Apollo Router Config Generator

Apollo Router is a high-performance graph router written in Rust for running Apollo Federation 2 supergraphs. It sits in front of your subgraphs and handles query planning, execution, and response composition.

This skill generates version-correct configuration. Router v1 and v2 have incompatible config schemas in several critical sections (CORS, JWT auth, connectors). Always determine the target version before generating any config.

Step 1: Version Selection

Ask the user before generating any config:

Which Apollo Router version are you targeting?

  [1] Router v2.x (recommended — current LTS, required for Connectors)
  [2] Router v1.x (legacy — end-of-support announced, security patches only)
  [3] Not sure — help me decide

If the user picks [3], display:

Quick guide:

  • Pick v2 if: you're starting fresh, using Apollo Connectors for REST APIs,
    or want backpressure-based overload protection.
  • Pick v1 if: you have an existing deployment and haven't migrated yet.
    Note: Apollo ended active support for v1.x. The v2.10 LTS (Dec 2025)
    is the current baseline. Migration is strongly recommended.

  Tip: If you have an existing router.yaml, you can auto-migrate it:
    router config upgrade router.yaml

Store the selection as ROUTER_VERSION=v1|v2 to gate all subsequent template generation.

Step 2: Environment Selection

Ask: Production or Development?

  • Production: security-hardened defaults (introspection off, sandbox off, homepage off, subgraph errors hidden, auth required, health check on)
  • Development: open defaults (introspection on, sandbox on, errors exposed, text logging)

Load the appropriate base template from:

  • templates/{version}/production.yaml
  • templates/{version}/development.yaml

Step 3: Feature Selection

Ask which features to include:

  • JWT Authentication
  • CORS (almost always yes for browser clients)
  • Operation Limits
  • Traffic Shaping / Rate Limiting
  • Telemetry (Prometheus, OTLP tracing, JSON logging)
  • APQ (Automatic Persisted Queries)
  • Connectors (REST API integration — Router v2 only; GA key is connectors, early v2 preview key was preview_connectors)
  • Subscriptions
  • Header Propagation
  • Response Caching (entity + root field caching with Redis — Router v2 only, v2.6.0+)

Step 4: Gather Parameters

For each selected feature, collect required values.

  • Use section templates from templates/{version}/sections/ for auth, cors, headers, limits, telemetry, and traffic-shaping.
  • For Connectors in v2, use templates/v2/sections/connectors.yaml as the source.
  • For APQ and subscriptions, copy the snippet from the selected base template (templates/{version}/production.yaml or templates/{version}/development.yaml) or from references.
  • Only offer Connectors when ROUTER_VERSION=v2.

CORS

  • List of allowed origins (never use "*" for production)

JWT Authentication

  • JWKS URL
  • Issuer(s) — note: v1 uses singular issuer, v2 uses plural issuers array

Connectors (v2 only)

  • Subgraph name and source name (used as connectors.sources.<subgraph>.<source>)
  • Optional $config values for connector runtime configuration
  • If migrating old v2 preview config, rename preview_connectors to connectors

Operation Limits

Present the tuning guidance:

Operation depth limit controls how deeply nested a query can be.

  Router default: 100 (permissive — allows very deep queries)
  Recommended starting point: 50

  Lower values (15–25) are more secure but will reject legitimate queries
  in schemas with deep entity relationships or nested fragments.
  Higher values (75–100) are safer for compatibility but offer less
  protection against depth-based abuse.

  Tip: Run your router in warn_only mode first to see what depths your
  real traffic actually uses, then tighten:
    limits:
      warn_only: true

What max_depth would you like? [default: 50]

The same principle applies to max_height, max_aliases, and max_root_fields.

Telemetry

  • OTEL collector endpoint (default: http://otel-collector:4317)
  • Prometheus listen port (default: 9090)
  • Trace sampling rate (default: 0.1 = 10%)

Traffic Shaping

  • Client-facing rate limit capacity (default: 1000 req/s)
  • Router timeout (default: 60s)
  • Subgraph timeout (default: 30s)

Response Caching (v2 only, v2.6.0+)

Security: data leakage risk. Before generating any response cache config, you MUST ask the user which types and fields return user-specific data. Cached data defaults to shared — subgraph responses without Cache-Control: private are visible to all users. User-specific subgraphs must return Cache-Control: private and have private_id configured on the router.

  • Ask: Which subgraphs serve user-specific data? (e.g., accounts, profiles, carts)
  • Ask: How do you identify users? (JWT sub claim, session token, API key)
  • Redis URL (default: redis://localhost:6379)
  • Default TTL (default: 5m)
  • Enable active invalidation? If yes: invalidation listen address and shared key
  • Use section template: templates/v2/sections/response-caching.yaml
  • For security requirements, schema directives, and advanced config: references/response-caching.md (start with the Security section)

Step 5: Generate Config

  1. Load the correct version template from templates/{version}/
  2. Assemble section templates for supported sectioned features, then merge base-template snippets for APQ/subscriptions as needed
  3. Inject user-provided parameters
  4. Add a comment block at the top stating the target version

Step 6: Validate

Run the post-generation checklist:

  • All env vars referenced in config are documented
  • CORS origins don't include wildcards (production)
  • Rate limiting is on router: (client-facing), not only all: (subgraph)
  • JWT uses issuers (v2) not issuer (v1), or vice versa
  • If production: introspection=false, sandbox=false, subgraph_errors=false
  • Health check is enabled
  • Homepage is disabled (production)
  • Run: router config validate <file> if Router binary is available

Required Validation Gate (always run)

After generating or editing any router.yaml, you MUST:

  1. Run validation/checklist.md and report pass/fail for each checklist item.
  2. Run router config validate <path-to-router.yaml> if Router CLI is available.
  3. If Router CLI is unavailable, state that explicitly and still complete the checklist.
  4. Do not present the configuration as final until validation is completed.

Step 7: Conditional Next Steps Handoff

After answering any Apollo Router request (config generation, edits, validation, or general Router guidance), decide whether the user already has runnable prerequisites:

  • GraphOS-managed path: APOLLO_KEY + APOLLO_GRAPH_REF, or
  • Local path: a composed supergraph.graphql plus reachable subgraphs

If prerequisites are already present, do not add extra handoff text.

If prerequisites are missing or unknown, end with a concise Next steps handoff (1-3 lines max) that is skill-first and command-free:

  1. Suggest the rover skill to compose or fetch the supergraph schema.
  2. Suggest continuing with apollo-router once the supergraph is ready to validate and run with the generated config.
  3. If subgraphs are missing, suggest apollo-server, graphql-schema, and graphql-operations skills to scaffold and test.

Do not include raw shell commands in this handoff unless the user explicitly asks for commands.

Quick Start (skill-first)

  1. Use this apollo-router skill to generate or refine router.yaml for your environment.
  2. Choose a runtime path:
    • GraphOS-managed path: provide APOLLO_KEY and APOLLO_GRAPH_REF (no local supergraph composition required).
    • Local supergraph path: use graphql-schema + apollo-server to define/run subgraphs, then use graphql-operations for smoke tests, then use the rover skill to compose or fetch supergraph.graphql.
  3. Use this apollo-router skill to validate readiness (validation/checklist.md) and walk through runtime startup inputs.

Default endpoint remains http://localhost:4000 when using standard Router listen defaults.

If the user asks for executable shell commands, provide them on request. Otherwise keep Quick Start guidance skill-oriented.

Running Modes

ModeCommandUse Case
Local schemarouter --supergraph ./schema.graphqlDevelopment, CI/CD
GraphOS managedAPOLLO_KEY=... APOLLO_GRAPH_REF=my-graph@prod routerProduction with auto-updates
Developmentrouter --dev --supergraph ./schema.graphqlLocal development
Hot reloadrouter --hot-reload --supergraph ./schema.graphqlSchema changes without restart

Environment Variables

VariableDescription
APOLLO_KEYAPI key for GraphOS
APOLLO_GRAPH_REFGraph reference (graph-id@variant)
APOLLO_ROUTER_CONFIG_PATHPath to router.yaml
APOLLO_ROUTER_SUPERGRAPH_PATHPath to supergraph schema
APOLLO_ROUTER_LOGLog level (off, error, warn, info, debug, trace)
APOLLO_ROUTER_LISTEN_ADDRESSOverride listen address

Reference Files

CLI Reference

router [OPTIONS]

Options:
  -s, --supergraph <PATH>    Path to supergraph schema file
  -c, --config <PATH>        Path to router.yaml configuration
      --dev                  Enable development mode
      --hot-reload           Watch for schema changes
      --log <LEVEL>          Log level (default: info)
      --listen <ADDRESS>     Override listen address
  -V, --version              Print version
  -h, --help                 Print help

Ground Rules

  • ALWAYS determine the target Router version (v1 or v2) before generating config
  • DEFAULT to v2 for new projects
  • ALWAYS include a comment block at top of generated config stating the target version
  • ALWAYS use --dev mode for local development (enables introspection and sandbox)
  • ALWAYS disable introspection, sandbox, and homepage in production
  • PREFER GraphOS managed mode for production (automatic updates, metrics)
  • USE --hot-reload for local development with file-based schemas
  • NEVER expose APOLLO_KEY in logs or version control
  • USE environment variables (${env.VAR}) for all secrets and sensitive config
  • PREFER YAML configuration over command-line arguments for complex setups
  • TEST configuration changes locally before deploying to production
  • WARN if user enables allow_any_origin or wildcard CORS in production
  • RECOMMEND router config upgrade router.yaml for v1 → v2 migration instead of regenerating from scratch
  • MUST run validation/checklist.md after every router config generation or edit
  • MUST run router config validate <file> when Router CLI is available
  • MUST report when CLI validation could not run (for example, Router binary missing)
  • MUST append a brief conditional handoff when runtime prerequisites are missing or unknown
  • MUST make this handoff skill-first and avoid raw shell commands unless the user explicitly requests commands
  • MUST keep Quick Start guidance skill-first and command-free unless the user explicitly requests commands
  • MUST state that Rover is required only for the local supergraph path; GraphOS-managed runtime does not require local Rover composition
  • USE max_depth: 50 as the default starting point, not 15 (too aggressive) or 100 (too permissive)
  • RECOMMEND warn_only: true for initial limits rollout to observe real traffic before enforcing
  • ONLY offer Response Caching when ROUTER_VERSION=v2 (requires v2.6.0+)
  • ALWAYS use ${env.*} for Redis URLs, passwords, and invalidation shared keys
  • NEVER enable response_cache.debug: true in production config
  • RECOMMEND combining Cache-Control headers (passive TTL) with @cacheTag (active invalidation) for production
  • ALWAYS ask which fields return user-specific data before generating response cache config — never assume all data is safe to cache as shared
  • ALWAYS configure private_id for subgraphs that serve user-specific data, and ensure those subgraphs return Cache-Control: private (via @cacheControl(scope: PRIVATE) in Apollo Server, or by setting the header directly in other frameworks)
  • NEVER generate response cache config without addressing private data — if the user says "no user-specific data", confirm explicitly before proceeding
  • ALWAYS bind the invalidation endpoint to 127.0.0.1, NEVER 0.0.0.0 in production

apollographql의 다른 스킬

apollo-client
apollographql
Apollo Client는 로컬 및 원격 데이터를 GraphQL로 관리할 수 있게 해주는 JavaScript용 종합 상태 관리 라이브러리입니다. 버전 4.x는 개선된 캐싱, 더 나은 TypeScript 지원, React 19 호환성을 제공합니다.
official
apollo-client
apollographql
Apollo Client 4.x를 사용하여 React 애플리케이션을 구축하기 위한 종합 가이드로, 쿼리, 뮤테이션, 캐싱 및 상태 관리를 다룹니다. 여러 React 프레임워크 및 설정을 지원합니다: 클라이언트 측 앱(Vite, CRA), React Server Components를 사용하는 Next.js App Router, 스트리밍 SSR을 지원하는 React Router 7, TanStack Start. 쿼리(useQuery, useLazyQuery), 뮤테이션(useMutation)을 위한 훅과 최신 React 18+ 및 19를 위한 Suspense 기반 패턴(useSuspenseQuery, useBackgroundQuery)을 포함합니다.
official
apollo-connectors
apollographql
REST API를 @source 및 @connect 지시문을 사용하여 GraphQL 슈퍼그래프에 통합합니다. 구조화된 5단계 프로세스를 제공합니다: API 구조 조사, 지시문으로 스키마 구현, rover supergraph compose를 통한 검증, 커넥터 실행, 테스트 커버리지. 헤더, 본문 페이로드, N+1 패턴을 위한 배칭, $env를 통한 환경 변수 주입을 포함한 요청 구성을 지원합니다. 필드 선택, 별칭, 중첩 데이터를 위한 하위 선택, 엔티티...를 포함한 응답 매핑을 처리합니다.
official
apollo-federation
apollographql
Apollo Federation은 여러 GraphQL API(서브그래프)를 하나의 통합된 슈퍼그래프로 구성할 수 있게 해줍니다.
official
apollo-ios
apollographql
Apollo iOS는 Apple 플랫폼을 위한 강력한 타입의 GraphQL 클라이언트입니다. GraphQL 작업과 스키마에서 Swift 타입을 생성하며, async/await 클라이언트, 정규화된 캐시(인메모리 또는 SQLite 기반), 쿼리, 뮤테이션 및 멀티파트 구독을 처리하는 플러그형 인터셉터 기반 HTTP 전송, 그리고 모든 작업 유형을 전달할 수 있는 선택적 WebSocket 전송(graphql-transport-ws)을 제공합니다.
official
apollo-kotlin
apollographql
Apollo Kotlin은 GraphQL 연산과 스키마에서 Kotlin 모델을 생성하는 강력한 타입의 GraphQL 클라이언트로, Android, JVM 및 Kotlin Multiplatform 프로젝트에서 사용할 수 있습니다.
official
apollo-mcp-server
apollographql
AI 에이전트를 GraphQL API에 연결하여 Model Context Protocol을 통해 내장된 인트로스펙션 및 작업 도구를 제공합니다. GraphQL 작업을 MCP 도구로 노출하며, 로컬 파일, GraphOS Studio 컬렉션, 지속적 쿼리 매니페스트의 세 가지 작업 소스를 지원합니다. 스키마 탐색 및 임시 쿼리 테스트를 위한 네 가지 인트로스펙션 도구(introspect, search, validate, execute)를 제공하며, 축약 표기법을 사용한 미니피케이션 모드로 토큰 사용량을 줄입니다. 정적 헤더를 통한 구성 가능한 인증,...
official
apollo-router-plugin-creator
apollographql
Apollo Router용 네이티브 Rust 플러그인을 생성합니다.
official