apollo-federation — скилл для Claude Code: схемы подграфов
Помогает писать схемы подграфов Apollo Federation: директивы, сущности с @key, ошибки композиции. Полезен, когда суперграф собирается из нескольких GraphQL-сервисов.
npx skills add apollographql/skills --skill apollo-federation -a claude-codeЧто делает apollo-federation
Скилл ведёт агента по синтаксису Federation 2.x. Каждый подграф подключается через @link с указанием URL спецификации и списком импортируемых директив, и агент подскажет, какие именно импортировать под вашу схему. Внутри — справочник по @key, @shareable, @external, @requires, @provides, @override, @inaccessible и @interfaceObject с примерами.
Отдельные файлы описывают паттерны для нескольких подграфов и правила композиции с кодами ошибок. Есть готовые рецепты: сущность с одним ключевым полем, добавление полей к сущности из другого подграфа, вычисляемые поля через @requires, общие типы значений через @shareable, заглушка сущности с resolvable: false.
Скилл вызывает rover — без установленного CLI проверка композиции не пройдёт. Агент советует rover supergraph compose для локальной проверки и rover subgraph check против продакшн-суперграфа. Версия v2.12 в примере приведена как образец: перед копированием сверьтесь с актуальным списком поддерживаемых версий, иначе композиция может не собраться.
Какие задачи решает
- создать схему нового подграфа для федеративного суперграфа
- описать сущность с ключом через @key
- отдать одно поле из нескольких подграфов через @shareable
- посчитать поле из внешних данных с @requires
- разобрать ошибку композиции и найти её код
Примеры запросов агенту
- добавь в схему подграфа сущность Product с ключом по id
- почему падает композиция: поле помечено @shareable в двух подграфах
- перенеси поле price в этот подграф через @override
Как установить apollo-federation
1Через Skills CLI (Vercel)
npx skills add apollographql/skills --skill apollo-federation -a claude-code2Вручную: положить файлы
~/.claude/skills/apollo-federation/SKILL.mdПапка скилла целиком; для одного проекта — .claude/skills/apollo-federation/
1Через Skills CLI (Vercel)
npx skills add apollographql/skills --skill apollo-federation -a codex2Вручную: положить файлы
.agents/skills/apollo-federation/SKILL.mdДля всех проектов — ~/.agents/skills/
1Через Skills CLI (Vercel)
npx skills add apollographql/skills --skill apollo-federation -a cursor2Вручную: положить файлы
.cursor/skills/apollo-federation/SKILL.mdCursor читает и .agents/skills/, и .claude/skills/
1GitHub CLI
gh skill install apollographql/skills apollo-federation2Вручную: положить файлы
.github/skills/apollo-federation/SKILL.md1Через Skills CLI (Vercel)
npx skills add apollographql/skills --skill apollo-federation -a gemini-cli2Командой платформы
gemini skills install https://github.com/apollographql/skills --path skills/apollo-federationВручную: положить файлы
.devin/skills/apollo-federation/SKILL.mdСтарый путь .windsurf/skills/ тоже читается
Через Skills CLI (Vercel)
npx skills add apollographql/skills --skill apollo-federation -a opencodeClaude.ai
Упакуйте папку в zip и загрузите в Settings → Capabilities → Skills
По шагам, с командами для каждой платформы: Как установить скилл в Claude Code: пять способов
Вопросы о apollo-federation
Как установить apollo-federation в Claude?
Выполните npx skills add apollographql/skills --skill apollo-federation -a claude-code. Скилл появится в ~/.claude/skills/apollo-federation/SKILL.md.
Что делает apollo-federation?
Подсказывает, как писать схемы подграфов Federation 2.x: подключение через @link, работа с директивами, паттерны нескольких подграфов и разбор ошибок композиции.
Что нужно для работы скилла?
CLI rover — через него идут rover supergraph compose и rover subgraph check. Схемы подходят для любой библиотеки, совместимой с Federation 2.x, например Apollo Server или GraphQL Yoga.
Исходный текст
SKILL.md · MIT
---
name: apollo-federation
description: >
Guide for authoring Apollo Federation subgraph schemas. Use this skill when:
(1) creating new subgraph schemas for a federated supergraph,
(2) defining or modifying entities with @key,
(3) sharing types/fields across subgraphs with @shareable,
(4) working with federation directives (@external, @requires, @provides, @override, @inaccessible),
(5) troubleshooting composition errors,
(6) any task involving federation schema design patterns.
license: MIT
compatibility: Works with any Federation 2.x compatible subgraph library (Apollo Server, GraphQL Yoga, etc.)
metadata:
author: apollographql
version: "1.0.2"
allowed-tools: Bash(rover:*) Read Write Edit Glob Grep
---
# Apollo Federation Schema Authoring
Apollo Federation enables composing multiple GraphQL APIs (subgraphs) into a unified supergraph.
## Federation 2 Schema Setup
Every Federation 2 subgraph must opt-in via `@link`:
```graphql
extend schema
@link(url: "https://specs.apollo.dev/federation/v2.12",
import: ["@key", "@shareable", "@external", "@requires", "@provides"])
```
Import only the directives your subgraph uses. The version shown (`v2.12`) is
illustrative — check the [Federation changelog](https://www.apollographql.com/docs/graphos/schema-design/federated-schemas/reference/versions)
for currently supported versions before copying it verbatim.
> A subgraph's `@link` version is a floor, not the composition version — see
> [Federation versions](references/composition.md#federation-versions-floor-vs-composition)
> for the full explanation.
## Core Directives Quick Reference
| Directive | Purpose | Example |
|-----------|---------|---------|
| `@key` | Define entity with unique key | `type Product @key(fields: "id")` |
| `@shareable` | Allow multiple subgraphs to resolve field | `type Position @shareable { x: Int! }` |
| `@external` | Reference field from another subgraph | `weight: Int @external` |
| `@requires` | Computed field depending on external fields | `shippingCost: Int @requires(fields: "weight")` |
| `@provides` | Conditionally resolve external field | `@provides(fields: "name")` |
| `@override` | Migrate field to this subgraph | `@override(from: "Products")` |
| `@inaccessible` | Hide from API schema | `internalId: ID! @inaccessible` |
| `@interfaceObject` | Add fields to entity interface | `type Media @interfaceObject` |
## Reference Files
Detailed documentation for specific topics:
- [Directives](references/directives.md) - All federation directives with syntax, examples, and rules
- [Schema Patterns](references/schema-patterns.md) - Multi-subgraph patterns and recipes
- [Composition](references/composition.md) - Composition rules, error codes, and debugging
## Key Patterns
### Entity Definition
```graphql
type Product @key(fields: "id") {
id: ID!
name: String!
price: Int
}
```
### Entity Contributions Across Subgraphs
```graphql
# Products subgraph
type Product @key(fields: "id") {
id: ID!
name: String!
price: Int
}
# Reviews subgraph
type Product @key(fields: "id") {
id: ID!
reviews: [Review!]!
averageRating: Float
}
```
### Computed Fields with @requires
```graphql
type Product @key(fields: "id") {
id: ID!
size: Int @external
weight: Int @external
shippingEstimate: String @requires(fields: "size weight")
}
```
### Value Types with @shareable
```graphql
type Money @shareable {
amount: Int!
currency: String!
}
```
### Entity Stub (Reference Without Contributing)
```graphql
type Product @key(fields: "id", resolvable: false) {
id: ID!
}
```
## Ground Rules
- ALWAYS use Federation 2.x syntax with `@link` directive
- ALWAYS import only the directives your subgraph uses
- NEVER use `@shareable` without ensuring all subgraphs return identical values for that field
- PREFER `@key` with single ID field for simple entity identification
- USE `rover supergraph compose` to validate composition locally
- USE `rover subgraph check` to validate against production supergraph
© apollographql · MIT · apollographql/skills