apollo-federation

作成者: apollographql

Apollo Federationは、複数のGraphQL API(サブグラフ)を統合されたスーパーグラフに構成することを可能にします。

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

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 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 - All federation directives with syntax, examples, and rules
  • Schema Patterns - Multi-subgraph patterns and recipes
  • Composition - 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

apollographqlのその他のスキル

apollo-ios
apollographql
Apollo iOSは、Appleプラットフォーム向けの強く型付けされたGraphQLクライアントです。GraphQLの操作とスキーマからSwiftの型を生成し、async/awaitクライアント、正規化キャッシュ(インメモリまたはSQLite対応)、クエリ、ミューテーション、マルチパートサブスクリプションを処理するプラグ可能なインターセプターベースのHTTPトランスポート、および任意の操作タイプを伝送可能なオプションのWebSocketトランスポート(graphql-transport-ws)を搭載しています。
apollo-router
apollographql
Apollo Routerは、Apollo Federation 2のスーパーグラフを実行するためにRustで書かれた高性能なグラフルーターです。サブグラフの前に配置され、クエリの計画、実行、レスポンスの合成を処理します。
apollo-router-plugin-creator
apollographql
Apollo Router用のネイティブRustプラグインを作成します。
apollo-server
apollographql
Apollo Server 5.xを使用してフレームワーク間でGraphQLサーバーを構築するための完全ガイド。スキーマ定義、リゾルバ、コンテキスト設定、TypeScriptサポートによるエラーハンドリングを網羅。プロトタイピング用のスタンドアロンモードと、Express、Fastify、Koa、サーバーレス環境との統合をサポート。リゾルバパターン、認証/認可、プラグイン、N+1問題防止のためのDataLoader、パフォーマンス最適化手法を含む。データソース、エラー...のリファレンスドキュメントを提供。
graphql-operations
apollographql
効率的で型安全なGraphQLオペレーションを作成し、フラグメントで整理するためのベストプラクティスガイド。クエリ、ミューテーション、サブスクリプション、フラグメントについて、命名規則、変数構文、ディレクティブの使用法を網羅。必要なフィールドのみをリクエストする、すべてのオペレーションに名前を付ける、ハードコードされた値の代わりに変数を使用する、キャッシュ可能性のためにIDフィールドを含めるといった基本原則を強調。フラグメントをコンポーネントと併置し、条件付きフィールドには@include/@skipディレクティブを使用することを推奨...
graphql-schema
apollographql
直感的で高性能かつ保守可能なGraphQLスキーマを設計するための業界ベストプラクティスガイド。クライアント中心の型構成、明示的なnull許容パターン、後方互換性のある進化戦略を含む中核設計原則を網羅。型、命名規則、カーソルベースのページネーション、エラーモデリング、セキュリティ考慮事項に関するリファレンスドキュメントを提供。インターフェース、ユニオン、入力型、ミューテーション、ID戦略に関する実践的なパターンをコード例とともに収録...
rover
apollographql
Apollo Rover CLIは、GraphQLスキーマ、フェデレーション、ローカルスーパーグラフ開発を管理するためのツールです。サブグラフスキーマの公開、取得、検証、フェデレーテッドスーパーグラフのローカルまたはGraphOS経由での構成を行います。スキーマチェック(デプロイ前検証)、リンティング、実行中のサーバーからのイントロスペクションを含みます。rover devコマンドは、開発ワークフロー向けに自動スキーマ構成を備えたローカルRouterを起動します。公開前チェック検証とスクリプト用のJSON出力を備えたCI/CDパターンをサポートします。必須条件...
rust-best-practices
apollographql
Apollo GraphQLのベストプラクティスハンドブックに基づく慣用的なRustコーディング標準。9つの主要領域をカバー:コーディングスタイルとイディオム、clippyリンティング、パフォーマンス最適化、エラーハンドリング、テストパターン、ジェネリクスとディスパッチ、タイプステートパターン、ドキュメンテーション、ポインタ安全性。クローンよりも借用を重視し、thiserror/anyhowを用いたResultベースのエラーハンドリング、リリースビルドでのパフォーマンスプロファイリングを強調。所有権パターン、パニック回避に関するクイックリファレンスガイダンスを含む...