Skip to content
Apollo Federation Schema Authoring

Apollo Federation Schema Authoring Skill

Apollo's official skill for writing Federation 2 subgraph schemas — entities and @key, @shareable, @external, @requires, @provides, @override, and reading composition errors.

GitHub Docs

Install

Install with the skills CLI

One command for Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf and dozens of other agents. Needs Node.js; the skill is fetched straight from apollographql/skills.

$ npx skills add apollographql/skills --skill apollo-federation

Run it in a terminal. The CLI finds the agents installed on your machine, asks which ones to add the skill to, and whether to install it into the folder you ran it from or for all your projects.

Other ways to install

Copy the whole skill folder — SKILL.md and any scripts or references beside it — into ~/.claude/skills/apollo-federation/, where Claude Code picks it up in every project. Only git is needed.

tmp=$(mktemp -d) && \
  git clone --depth 1 --branch main https://github.com/apollographql/skills.git "$tmp" && \
  mkdir -p ~/.claude/skills && \
  cp -R "$tmp"/skills/apollo-federation ~/.claude/skills/apollo-federation

No scripts or references next to it? Saving the SKILL.md alone as ~/.claude/skills/apollo-federation/SKILL.md works too.

Using another agent? Its personal skills folder
Codex
~/.agents/skills/
Cursor
~/.cursor/skills/
GitHub Copilot
~/.copilot/skills/
Gemini CLI
~/.gemini/skills/
Windsurf
~/.codeium/windsurf/skills/
OpenCode
~/.config/opencode/skills/

About

  • Federation 2 @link setup and version pinning
  • Entity design with @key and reference resolvers
  • Decision guidance for @shareable, @external, @requires, @provides, @override, @inaccessible
  • Maps Rover composition errors back to the schema decision that caused them
  • Works with any Federation 2.x subgraph library, not just Apollo Server

Federation is where GraphQL schema design stops being local. A field that looks fine inside one subgraph can break composition of the supergraph, and the error you get back names a directive rather than the decision that caused it. This is Apollo's official skill for that work.

It covers Federation 2 subgraph authoring end to end: declaring the @link to the federation spec at the right version, defining entities with @key and choosing key fields that actually resolve, and the reference resolver that makes an entity reachable from other subgraphs.

The directives, and when each is the right answer
  • @shareable for a field that more than one subgraph can resolve
  • @external plus @requires for a field that needs data owned elsewhere
  • @provides for the case where a subgraph can return a related entity's field without a round trip
  • @override for migrating field ownership between subgraphs without a flag day
  • @inaccessible for a field that exists in a subgraph but must not appear in the public supergraph
Composition errors

The skill treats composition failures as first-class content rather than an appendix — mapping the message Rover prints back to the schema decision behind it, which is the part that is hard to guess.

Details

MIT licensed, version 1.0.2, from apollographql/skills. It is library-agnostic: anything Federation 2.x compatible works, including Apollo Server and GraphQL Yoga. Allowed tools are Bash(rover:*), Read, Write, Edit, Glob and Grep, so the agent can compose locally and iterate on the error output.

Try it

Once installed, ask your agent something like:

Use the apollo-federation skill to move the Order.total field from the orders subgraph to billing with @override, without breaking composition.

SKILL.md

The instructions your agent loads, as published by Apollo GraphQL.

SKILL.md
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:

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
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
DirectivePurposeExample
@keyDefine entity with unique keytype Product @key(fields: "id")
@shareableAllow multiple subgraphs to resolve fieldtype Position @shareable { x: Int! }
@externalReference field from another subgraphweight: Int @external
@requiresComputed field depending on external fieldsshippingCost: Int @requires(fields: "weight")
@providesConditionally resolve external field@provides(fields: "name")
@overrideMigrate field to this subgraph@override(from: "Products")
@inaccessibleHide from API schemainternalId: ID! @inaccessible
@interfaceObjectAdd fields to entity interfacetype 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
type Product @key(fields: "id") {
  id: ID!
  name: String!
  price: Int
}
Entity Contributions Across Subgraphs
# 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
type Product @key(fields: "id") {
  id: ID!
  size: Int @external
  weight: Int @external
  shippingEstimate: String @requires(fields: "size weight")
}
Value Types with @shareable
type Money @shareable {
  amount: Int!
  currency: String!
}
Entity Stub (Reference Without Contributing)
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
Install

Skill: Apollo MCP Server

by Apollo GraphQL

Sets up Apollo MCP Server so an AI agent can call a GraphQL API as MCP tools — defining tools from named operations, or exposing introspect/search/validate/execute for open-ended schemas.

New

Matteo Collina's Fastify skill: a minimal server plus 19 rule files on plugins, routes, JSON Schema, hooks, auth, testing with inject(), Pino logging, TypeScript and deployment.

Featured

Shopify's official skill for writing Admin GraphQL queries and mutations — it searches the live API docs and validates every operation against the schema before handing you code.

Skill: uv

by Astral

New

Astral's official skill that teaches coding agents to use uv for Python scripts, projects, tools and type checking, and to migrate pip, pipx and pyenv commands to their uv equivalents.

Browse all skills →