apollo-router by apollographql/skills
npx skills add https://github.com/apollographql/skills --skill apollo-routerApollo Router 是一个用 Rust 编写的高性能图路由器,用于运行 Apollo Federation 2 超级图。它位于您的子图之前,处理查询规划、执行和响应组合。
此技能生成版本正确的配置。 Router v1 和 v2 在几个关键部分(CORS、JWT 身份验证、连接器)存在不兼容的配置模式。在生成任何配置之前,请务必确定目标版本。
在生成任何配置之前询问用户:
您目标使用的 Apollo Router 版本是哪个?
[1] Router v2.x (推荐 — 当前 LTS,连接器功能必需)
[2] Router v1.x (旧版 — 已宣布停止支持,仅提供安全补丁)
[3] 不确定 — 帮我决定
如果用户选择 [3],则显示:
快速指南:
• 选择 v2 如果:您是新项目,使用 Apollo Connectors 连接 REST API,
或者需要基于背压的过载保护。
• 选择 v1 如果:您已有现有部署且尚未迁移。
注意:Apollo 已停止对 v1.x 的主动支持。v2.10 LTS (2025年12月)
是当前的基准版本。强烈建议迁移。
提示:如果您已有现有的 router.yaml 文件,可以自动迁移它:
router config upgrade router.yaml
将选择存储为 ROUTER_VERSION=v1|v2,以控制所有后续模板的生成。
询问:生产环境还是开发环境?
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
从以下位置加载相应的基础模板:
templates/{version}/production.yamltemplates/{version}/development.yaml询问要包含哪些功能:
connectors,早期 v2 预览版键为 preview_connectors)为每个选定的功能收集所需的值。
auth、cors、headers、limits、telemetry 和 traffic-shaping,使用 templates/{version}/sections/ 中的部分模板。templates/v2/sections/connectors.yaml 作为源。templates/{version}/production.yaml 或 templates/{version}/development.yaml)或参考文档中复制代码片段。ROUTER_VERSION=v2 时才提供连接器选项。"*")issuer,v2 使用复数 issuers 数组connectors.sources.<subgraph>.<source>)$config 值preview_connectors 重命名为 connectors提供调优指导:
操作深度限制控制查询可以嵌套多深。
Router 默认值:100 (宽松 — 允许非常深的查询)
推荐的起始点:50
较低的值 (15–25) 更安全,但对于具有深层实体关系或嵌套片段的模式,
会拒绝合法的查询。
较高的值 (75–100) 兼容性更好,但针对基于深度的滥用保护较少。
提示:首先在 warn_only 模式下运行您的路由器,以查看您的实际流量
实际使用的深度,然后再收紧限制:
limits:
warn_only: true
您希望设置什么 max_depth?[默认:50]
同样的原则适用于 max_height、max_aliases 和 max_root_fields。
http://otel-collector:4317)9090)0.1 = 10%)templates/{version}/ 加载正确版本的模板运行 生成后检查清单:
router:(面向客户端),而不仅仅是 all:(子图)issuers (v2) 而不是 issuer (v1),反之亦然router config validate <file>在生成或编辑任何 router.yaml 之后,您必须:
validation/checklist.md 并报告每个检查清单项目的通过/失败情况。router config validate <path-to-router.yaml>。在回答任何 Apollo Router 请求(配置生成、编辑、验证或一般 Router 指导)之后,判断用户是否已具备可运行的先决条件:
APOLLO_KEY + APOLLO_GRAPH_REF,或者supergraph.graphql 加上可访问的子图如果先决条件已经具备,则不要添加额外的交接文本。
如果先决条件缺失或未知,则以简洁的后续步骤交接结束(最多 1-3 行),该交接以技能优先且不包含命令:
rover 技能来组合或获取超级图模式。apollo-router 来验证并使用生成的配置运行。apollo-server、graphql-schema 和 graphql-operations 技能来搭建和测试。除非用户明确要求命令,否则不要在此交接中包含原始 shell 命令。
apollo-router 技能为您的环境生成或完善 router.yaml。APOLLO_KEY 和 APOLLO_GRAPH_REF(无需本地超级图组合)。graphql-schema + apollo-server 来定义/运行子图,然后使用 graphql-operations 进行冒烟测试,接着使用 rover 技能来组合或获取 supergraph.graphql。apollo-router 技能验证准备情况(validation/checklist.md)并逐步完成运行时启动输入。当使用标准的 Router 监听默认值时,默认端点保持为 http://localhost:4000。
如果用户要求可执行的 shell 命令,请根据请求提供。否则,保持快速开始指南以技能为导向。
| 模式 | 命令 | 使用场景 |
|---|---|---|
| 本地模式 | router --supergraph ./schema.graphql | 开发、CI/CD |
| GraphOS 托管 | APOLLO_KEY=... APOLLO_GRAPH_REF=my-graph@prod router | 生产环境,带自动更新 |
| 开发模式 | router --dev --supergraph ./schema.graphql | 本地开发 |
| 热重载 | router --hot-reload --supergraph ./schema.graphql | 无需重启即可处理模式更改 |
| 变量 | 描述 |
|---|---|
APOLLO_KEY | GraphOS 的 API 密钥 |
APOLLO_GRAPH_REF | 图引用 (graph-id@variant) |
APOLLO_ROUTER_CONFIG_PATH | router.yaml 的路径 |
APOLLO_ROUTER_SUPERGRAPH_PATH | 超级图模式的路径 |
APOLLO_ROUTER_LOG | 日志级别 (off, error, warn, info, debug, trace) |
APOLLO_ROUTER_LISTEN_ADDRESS | 覆盖监听地址 |
router [OPTIONS]
Options:
-s, --supergraph <PATH> 超级图模式文件的路径
-c, --config <PATH> router.yaml 配置文件的路径
--dev 启用开发模式
--hot-reload 监视模式更改
--log <LEVEL> 日志级别 (默认:info)
--listen <ADDRESS> 覆盖监听地址
-V, --version 打印版本
-h, --help 打印帮助
--dev 模式(启用自省和沙盒)--hot-reloadAPOLLO_KEY${env.VAR}) 来存储所有机密和敏感配置allow_any_origin 或通配符 CORS,发出警告router config upgrade router.yaml 进行 v1 → v2 迁移,而不是从头开始重新生成validation/checklist.mdrouter config validate <file>max_depth: 50 作为默认起始点,而不是 15(过于激进)或 100(过于宽松)warn_only: true,以便在强制执行之前观察实际流量每周安装量
157
代码仓库
GitHub 星标数
31
首次出现
2026年2月12日
安全审计
安装在
github-copilot151
codex149
opencode148
gemini-cli148
amp147
kimi-cli147
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.
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.
Ask: Production or Development?
Load the appropriate base template from:
templates/{version}/production.yamltemplates/{version}/development.yamlAsk which features to include:
connectors, early v2 preview key was preview_connectors)For each selected feature, collect required values.
templates/{version}/sections/ for auth, cors, headers, limits, telemetry, and traffic-shaping.templates/v2/sections/connectors.yaml as the source.templates/{version}/production.yaml or templates/{version}/development.yaml) or from references."*" for production)issuer, v2 uses plural issuers arrayconnectors.sources.<subgraph>.<source>)$config values for connector runtime configurationpreview_connectors to connectorsPresent 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.
http://otel-collector:4317)9090)0.1 = 10%)templates/{version}/Run the post-generation checklist:
router: (client-facing), not only all: (subgraph)issuers (v2) not issuer (v1), or vice versarouter config validate <file> if Router binary is availableAfter generating or editing any router.yaml, you MUST:
validation/checklist.md and report pass/fail for each checklist item.router config validate <path-to-router.yaml> if Router CLI is available.After answering any Apollo Router request (config generation, edits, validation, or general Router guidance), decide whether the user already has runnable prerequisites:
APOLLO_KEY + APOLLO_GRAPH_REF, orsupergraph.graphql plus reachable subgraphsIf 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:
rover skill to compose or fetch the supergraph schema.apollo-router once the supergraph is ready to validate and run with the generated config.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.
apollo-router skill to generate or refine router.yaml for your environment.APOLLO_KEY and APOLLO_GRAPH_REF (no local supergraph composition required).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.apollo-router skill to validate readiness () 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.
| Mode | Command | Use Case |
|---|---|---|
| Local schema | router --supergraph ./schema.graphql | Development, CI/CD |
| GraphOS managed | APOLLO_KEY=... APOLLO_GRAPH_REF=my-graph@prod router | Production with auto-updates |
| Development | router --dev --supergraph ./schema.graphql | Local development |
| Hot reload | router --hot-reload --supergraph ./schema.graphql | Schema changes without restart |
| Variable | Description |
|---|---|
APOLLO_KEY | API key for GraphOS |
APOLLO_GRAPH_REF | Graph reference (graph-id@variant) |
APOLLO_ROUTER_CONFIG_PATH | Path to router.yaml |
APOLLO_ROUTER_SUPERGRAPH_PATH | Path to supergraph schema |
APOLLO_ROUTER_LOG |
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
--dev mode for local development (enables introspection and sandbox)--hot-reload for local development with file-based schemasAPOLLO_KEY in logs or version control${env.VAR}) for all secrets and sensitive configallow_any_origin or wildcard CORS in productionrouter config upgrade router.yaml for v1 → v2 migration instead of regenerating from scratchvalidation/checklist.md after every router config generation or editWeekly Installs
157
Repository
GitHub Stars
31
First Seen
Feb 12, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
github-copilot151
codex149
opencode148
gemini-cli148
amp147
kimi-cli147
ROUTER_VERSION=v2.validation/checklist.md| Log level (off, error, warn, info, debug, trace) |
APOLLO_ROUTER_LISTEN_ADDRESS | Override listen address |
router config validate <file> when Router CLI is availablemax_depth: 50 as the default starting point, not 15 (too aggressive) or 100 (too permissive)warn_only: true for initial limits rollout to observe real traffic before enforcing