api-graphql-federation
Use when the user asks about GraphQL federation, Apollo Federation 2, composing subgraphs into one supergraph, @key, @shareable, Apollo Router or rover…
от j4flmao★ 47 звёзд на GitHub
Установить api-graphql-federation в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Об этом скилле
GraphQL Federation
Purpose
Compose multiple team-owned GraphQL services (subgraphs) into one supergraph served by a router, so each team ships its part of the graph independently. The skill covers where to draw subgraph boundaries, how entities are shared and resolved, how composition is validated, and how to configure the router safely.
Agent Protocol
Trigger
Exact user phrases: "graphql federation", "apollo federation", "supergraph", "subgraph", "schema composition", "@key directive", "@requires", "@shareable", "apollo router", "rover compose", "federate graphql across teams".
Input Context
- Domains/teams and which data each owns.
- Existing GraphQL servers and libraries (Apollo Server +
@apollo/subgraph, GraphQL Yoga, Strawberry, gqlgen, DGS, Hot Chocolate). - Managed (GraphOS) or self-hosted composition; router choice (Apollo Router, or alternatives such as Hive Gateway / Cosmo Router).
- Auth model and latency budget.
Output Artifact
Subgraph schemas with federation directives, entity resolvers, supergraph.yaml, CI check commands, and router.yaml. No files unless requested.
Response Format
Subgraphs: {name -> owner team, owned types}
Entities: {Type @key(fields) -> origin subgraph, contributing subgraphs}
Cross-subgraph fields: {field @requires/@provides}
Composition: {rover supergraph compose | GraphOS managed} + check in CI
Router: auth {jwt}, limits {depth/aliases}, demand control {mode}, timeouts {per subgraph}
When Federation Fits
| Situation | Recommendation |
|---|---|
| One team, one service | Single GraphQL server; federation adds a router hop and composition overhead |
| Several teams, distinct domains, all GraphQL-capable | Federation |
| Mostly REST/gRPC backends owned by others | Wrap them (GraphQL Mesh, Apollo Connectors, or a BFF subgraph) and compose |
| Strong need for cross-domain transactions in one mutation | Fix domain boundaries first; federation does not provide transactions |
Boundary rule: a subgraph per bounded context/team, not per database table. Many tiny subgraphs multiply query-plan fetches.
Subgraph Schemas (Federation 2)
Every Federation 2 subgraph opts in with @link and imports the directives it uses.
# accounts subgraph (origin of User)
extend schema
@link(url: "https://specs.apollo.dev/federation/v2.7", import: ["@key", "@shareable"])
type User @key(fields: "id") {
id: ID!
name: String!
email: String!
}
type Query {
me: User
}
# orders subgraph contributes User.orders
extend schema
@link(url: "https://specs.apollo.dev/federation/v2.7", import: ["@key"])
type User @key(fields: "id") {
id: ID!
orders(first: Int = 20): [Order!]!
}
type Order @key(fields: "id") {
id: ID!
totalCents: Int!
status: OrderStatus!
}
enum OrderStatus { PENDING PAID SHIPPED CANCELLED }
In Federation 2, extend type / @extends is not needed to contribute fields to an entity; key fields are shareable automatically. Non-key fields defined in more than one subgraph must be marked @shareable (or one definition @external).
Directives
| Directive | Meaning |
|---|---|
@key(fields: "id") |
Declares an entity and the fields the router uses to reference it. Multiple keys allowed; resolvable: false for reference-only stubs |
@shareable |
Field (or type) may be resolved by more than one subgraph |
@external |
Field is defined elsewhere; used together with @requires or @provides |
@requires(fields: "weight") |
This field needs other subgraphs' fields; the router fetches them first and passes them in the representation |
@provides(fields: "name") |
On a field returning an entity: this subgraph can return those (@external) fields at this path, saving a fetch |
@override(from: "old") |
Moves a field's ownership to this subgraph (incremental migration; progressive label supported) |
@inaccessible |
Hides a field/type from the public API schema while still usable for composition |
@interfaceObject |
Lets a subgraph add fields to all implementations of an entity interface |
@composeDirective |
Preserves a custom directive in the supergraph |
@requires example:
# shipping subgraph
extend schema
@link(url: "https://specs.apollo.dev/federation/v2.7", import: ["@key", "@external", "@requires"])
type Product @key(fields: "id") {
id: ID!
weightGrams: Int @external
shippingCostCents: Int @requires(fields: "weightGrams")
}
Entity Resolution
The router asks a subgraph for entities through the _entities(representations: [_Any!]!) field. Each representation contains __typename, the key fields, and any @requires fields. The subgraph resolves them in __resolveReference; batch with DataLoader because one _entities call can carry many representations.
import { ApolloServer } from '@apollo/server';
import { startStandaloneServer } from '@apollo/server/standalone';
import { buildSubgraphSchema } from '@apollo
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
- references/entity-resolution.md
- references/federated-tracing.md
- references/federation-architecture.md
- references/federation-cost-management.md
- references/federation-deployment.md
- references/federation-migration-monolith.md
- references/federation-performance.md
- references/federation-security.md
- references/federation-testing.md
- references/federation-vs-mesh.md
- references/graphql-federation-advanced.md
- references/graphql-federation-fundamentals.md
- references/supergraph-composition.md
- references/supergraph-config.md
FAQ
Что делает скилл api-graphql-federation?
Use when the user asks about GraphQL federation, Apollo Federation 2, composing subgraphs into one supergraph, @key, @shareable, Apollo Router or rover compose. Produces a federated supergraph design with subgraph code. Not for single-service GraphQL schemas (use backend-graphql-patterns).
Как установить скилл api-graphql-federation?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл api-graphql-federation запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
AnthropicGuide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
claude-api
AnthropicReference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
algorithmic-art
AnthropicCreating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
mcp-integration
AnthropicThis skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…