apollo-federation
โดย apollographql
Apollo Federation ช่วยให้สามารถรวม GraphQL API หลายตัว (ซับกราฟ) เข้าด้วยกันเป็นซูเปอร์กราฟแบบรวมศูนย์
npx skills add https://github.com/apollographql/skills --skill apollo-federationApollo 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.
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 - 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
@linkdirective - ALWAYS import only the directives your subgraph uses
- NEVER use
@shareablewithout ensuring all subgraphs return identical values for that field - PREFER
@keywith single ID field for simple entity identification - USE
rover supergraph composeto validate composition locally - USE
rover subgraph checkto validate against production supergraph
Skills เพิ่มเติมจาก apollographql
apollo-client
apollographql
Apollo Client เป็นไลบรารีจัดการสถานะที่ครอบคลุมสำหรับ JavaScript ที่ช่วยให้คุณจัดการข้อมูลทั้งในเครื่องและระยะไกลด้วย GraphQL เวอร์ชัน 4.x นำเสนอการแคชที่ปรับปรุงดีขึ้น การรองรับ TypeScript ที่ดีขึ้น และความเข้ากันได้กับ React 19
official
apollo-client
apollographql
คู่มือที่ครอบคลุมสำหรับการสร้างแอปพลิเคชัน React ด้วย Apollo Client 4.x ครอบคลุมการสอบถาม การกลายพันธุ์ การแคช และการจัดการสถานะ รองรับเฟรมเวิร์ก React และการตั้งค่าหลายแบบ: แอปฝั่งไคลเอ็นต์ (Vite, CRA), Next.js App Router พร้อม React Server Components, React Router 7 พร้อมสตรีมมิ่ง SSR และ TanStack Start รวมถึง hooks สำหรับการสอบถาม (useQuery, useLazyQuery), การกลายพันธุ์ (useMutation) และรูปแบบที่ใช้ Suspense (useSuspenseQuery, useBackgroundQuery) สำหรับ React 18+ และ 19 สมัยใหม่...
official
apollo-connectors
apollographql
รวม REST API เข้ากับ GraphQL supergraphs โดยใช้ @source และ @connect directives มีกระบวนการ 5 ขั้นตอนที่มีโครงสร้าง: ศึกษาโครงสร้าง API, ใช้ schema กับ directives, ตรวจสอบผ่าน rover supergraph compose, ดำเนินการ connectors, และทดสอบครอบคลุม รองรับการกำหนดค่าคำขอรวมถึง headers, body payloads, การทำ batch สำหรับรูปแบบ N+1, และการแทรกตัวแปรสภาพแวดล้อมผ่าน $env จัดการการแมปการตอบสนองด้วยการเลือกฟิลด์, การตั้งชื่ออื่น, การเลือกย่อยสำหรับข้อมูลที่ซ้อนกัน, และ entity...
official
apollo-ios
apollographql
Apollo iOS เป็น GraphQL ไคลเอนต์แบบ strongly-typed สำหรับแพลตฟอร์ม Apple โดยสร้างประเภท Swift จากการดำเนินการและสคีมา GraphQL ของคุณ และมาพร้อมกับไคลเอนต์แบบ async/await, แคชแบบ normalized (ในหน่วยความจำหรือ backed โดย SQLite), การขนส่ง HTTP แบบ interceptor-based ที่เสียบได้ซึ่งจัดการ queries, mutations, และ multipart subscriptions, และการขนส่ง WebSocket แบบเลือกได้ (graphql-transport-ws) ที่สามารถรองรับการดำเนินการทุกประเภท
official
apollo-kotlin
apollographql
Apollo Kotlin เป็นไคลเอนต์ GraphQL ที่มีการกำหนดชนิดข้อมูลอย่างเข้มงวด ซึ่งสร้างโมเดล Kotlin จากการดำเนินการและสคีมา GraphQL ของคุณ สามารถใช้ในโปรเจกต์ Android, JVM และ Kotlin Multiplatform ได้
official
apollo-mcp-server
apollographql
เชื่อมต่อ AI agents กับ GraphQL APIs ผ่าน Model Context Protocol พร้อมเครื่องมือ introspection และ operation ในตัว เปิดเผย GraphQL operations เป็น MCP tools; รองรับแหล่ง operation สามประเภท: ไฟล์ในเครื่อง, คอลเลกชัน GraphOS Studio, และ persisted query manifests มีเครื่องมือ introspection สี่อย่าง (introspect, search, validate, execute) สำหรับการสำรวจ schema และทดสอบ query แบบ ad-hoc; โหมด minification ลดการใช้ token ด้วยสัญกรณ์แบบกะทัดรัด กำหนดค่าการรับรองความถูกต้องผ่าน static headers,...
official
apollo-router
apollographql
Apollo Router เป็นกราฟเราเตอร์ประสิทธิภาพสูงที่เขียนด้วยภาษา Rust สำหรับรันซูเปอร์กราฟของ Apollo Federation 2 โดยจะอยู่ด้านหน้าซับกราฟของคุณและจัดการการวางแผนคิวรี การดำเนินการ และการประกอบคำตอบ
official
apollo-router-plugin-creator
apollographql
สร้างปลั๊กอิน Rust ดั้งเดิมสำหรับ Apollo Router
official