Details
# Apollo GraphQL Agent Skills
[](LICENSE)
[](#skills)
A collection of skills for AI coding agents working with Apollo GraphQL tools and technologies.
Apollo Skills follow the [Agent Skills](https://agentskills.io/) format and are available on [skills.sh](https://skills.sh/).
## Installation
Install skills using the [Skills CLI](https://skills.sh/docs/cli):
```bash
npx skills add apollographql/skills
```
The CLI guides you through an interactive installation:
1. **Select skills** - Choose which skills to install
2. **Select agents** - Pick target agents (Claude Code, Codex, Cursor, Gemini CLI, Goose, OpenCode)
3. **Installation scope** - Project (committed with your code) or Global
4. **Installation method** - Symlink (recommended) or Copy
```
◇ Found 11 skills
│
◆ Select skills to install
│ ◼ apollo-client
│ ◼ apollo-connectors
│ ◼ apollo-server
│ ○ ...
└
```
## Claude Code Plugin
You can also install skills as a [Claude Code plugin](https://code.claude.com/docs/en/discover-plugins):
First, add the marketplace:
```bash
/plugin marketplace add apollographql/skills
```
Then, install the plugin:
```bash
/plugin install apollo-skills@apollo-marketplace
```
Once installed, skills are available as namespaced slash commands:
| Slash Command | Description |
|---|---|
| `/apollo-skills:apollo-client` | Apollo Client 4.x for React — queries, mutations, caching, local state |
| `/apollo-skills:apollo-connectors` | Apollo Connectors — integrate REST APIs into GraphQL |
| `/apollo-skills:apollo-ios` | Apollo iOS — GraphQL client for Swift (iOS, macOS, tvOS, watchOS, visionOS) |
| `/apollo-skills:apollo-kotlin` | Apollo Kotlin — GraphQL client for Android and Kotlin |
| `/apollo-skills:apollo-mcp-server` | Apollo MCP Server — connect AI agents with GraphQL APIs |
| `/apollo-skills:apollo-server` | Apollo Server 4.x — schemas, resolvers, auth, plugins |
| `/apollo-skills:graphql-operations` | GraphQL operations — queries, mutations, fragments |
| `/apollo-skills:graphql-schema` | GraphQL schema design — types, naming, pagination, errors |
| `/apollo-skills:rover` | Rover CLI — schema management and local supergraph development |
| `/apollo-skills:rust-best-practices` | Rust best practices — idiomatic Rust following Apollo conventions |
| `/apollo-skills:skill-creator` | Skill creator — guide for creating new Apollo skills |
## GitHub CLI
You can also install skills with the [GitHub CLI](https://cli.github.com/) using `gh skill` (preview):
```bash
# Install skills into the current project for Claude Code
gh skill install apollographql/skills --agent claude-code
# Install at user scope (available everywhere)
gh skill install apollographql/skills --agent claude-code --scope user
# Pin to a specific release (skipped during updates so it won't auto-upgrade)
gh skill install apollographql/skills --pin v1.0.0 --agent claude-code
# Preview skills before installing
gh skill preview apollographql/skills
```
`--agent` supports many hosts beyond Claude Code (Cursor, Codex, Gemini CLI, GitHub Copilot, and more); run `gh skill install --help` for the full list.
## Releases
Releases are tagged with semver and published automatically whenever a content change is merged to `main`. The full list lives at [github.com/apollographql/skills/releases](https://github.com/apollographql/skills/releases).
| Install path | What you get |
|---|---|
| `gh skill install apollographql/skills <name>` | Latest tagged release |
| `gh skill install apollographql/skills <name> --pin v1.0.0` | Pinned to a specific release (skipped during updates) |
| `npx skills add apollographql/skills@<name>` | Latest content from `main` (no tag) |
| Claude Code plugin (`claude plugin install`) | Latest plugin version (auto-updates via `claude plugin update`) |
If you need stability, pin via `gh skill install … --pin vX.Y.Z`. Pinned skills are skipped during `gh skill upgrade`, so you upgrade deliberately. For the freshest content, the other paths track `main` HEAD directly.
## Available Skills
### apollo-connectors
Write Apollo Connectors schemas to integrate REST APIs into GraphQL.
**Install:**
```bash
npx skills add apollographql/skills@apollo-connectors
```
**Use when:**
- Connecting REST APIs to a GraphQL supergraph
- Writing `@source` and `@connect` directives
- Implementing entity resolvers with batching
- Validating connector schemas with `rover`
**Categories covered:**
- Selection mapping grammar
- HTTP methods and headers
- Variable interpolation (`$args`, `$this`, `$config`)
- Entity patterns and `@key` directives
- Batch requests with `@listSize`
**Examples:**
- "Connect my REST API to my GraphQL schema"
- "Write a connector for this OpenAPI spec"
- "Add entity resolvers with batching for my users endpoint"
**References:**
[SKILL.md](skills/apollo-connectors/SKILL.md) ·
[Grammar](skills/apollo-connectors/references/grammar.md) ·
[Methods](skills/apollo-connectors/references/methods.md) ·
[Variables](skills/apollo-connectors/references/variables.md) ·
[Entities](skills/apollo-connectors/references/entities.md) ·
[Validation](skills/apollo-connectors/references/validation.md) ·
[Troubleshooting](skills/apollo-connectors/references/troubleshooting.md)
---
### apollo-federation
Author Apollo Federation subgraph schemas with entities, sharing, and cross-subgraph field resolution.
**Install:**
```bash
npx skills add apollographql/skills --skill apollo-federation
```
**Use when:**
- Creating new subgraph schemas for a federated supergraph
- Defining or modifying entities with `@key`
- Sharing types/fields across subgraphs with `@shareable`
- Working with federation directives (`@external`, `@requires`, `@provides`, `@override`)
- Troubleshooting composition errors
**Categories covered:**
- Entity definition and `@key` patterns (compound, multiple, differing)
- Reference resolvers and computed fields
- Value types with `@shareable`
- Field migration with `@override` (including progressive rollout)
- Entity interfaces with `@interfaceObject`
- Common composition errors and fixes
**Examples:**
- "Create a federated subgraph for my products service"
- "Add a computed field that requires data from another subgraph"
- "Migrate this field from one subgraph to another"
**References:**
[SKILL.md](skills/apollo-federation/SKILL.md) ·
[Directives](skills/apollo-federation/references/directives.md) ·
[Schema Patterns](skills/apollo-federation/references/schema-patterns.md) ·
[Composition](skills/apollo-federation/references/composition.md)
---
### apollo-mcp-server
Configure and use Apollo MCP Server to connect AI agents with GraphQL APIs.
**Install:**
```bash
npx skills add apollographql/skills@apollo-mcp-server
```
**Use when:**
- Setting up Apollo MCP Server for Claude or other AI agents
- Defining MCP tools from GraphQL operations
- Using introspection tools (introspect, search, validate, execute)
- Troubleshooting MCP server connectivity issues
**Categories covered:**
- Server configuration (endpoints, schemas, headers)
- Built-in tools and compact notation
- Operation sources (files, collections, persisted queries)
- Authentication and security
- Health checks and debugging
**Examples:**
- "Set up Apollo MCP Server for my GraphQL endpoint"
- "Configure MCP tools from my GraphQL operations"
- "Debug MCP server connection issues"
**References:**
[SKILL.md](skills/apollo-mcp-server/SKILL.md) ·
[Tools](skills/apollo-mcp-server/references/tools.md) ·
[Configuration](skills/apollo-mcp-server/references/configuration.md) ·
[Troubleshooting](skills/apollo-mcp-server/references/troubleshooting.md)
---
### apollo-router
Configure and run Apollo Router for federated GraphQL supergraphs.
**Install:**
```bash
npx skills add apollographql/skills@apollo-router
```
**Use when:**
- Setting up Apollo Router to run a supergraph
- Configuring routing, headers, or CORS
- Implementing custom plugins (Rhai scripts or coprocessors)
- Configuring telemetry and observability
- Troubleshooting Router performance or connectivity issues
**Categories covered:**
- Installation and quick start
- Router configuration (YAML)
- Header propagation and manipulation
- CORS and authentication
- Rhai scripts and coprocessors
- Telemetry (tracing, metrics, logging)
**Examples:**
- "Set up Apollo Router for my supergraph"
- "Configure CORS for my Router"
- "Add header propagation for authentication"
**References:**
[SKILL.md](skills/apollo-router/SKILL.md) ·
[Configuration](skills/apollo-router/references/configuration.md) ·
[Headers](skills/apollo-router/references/headers.md) ·
[Plugins](skills/apollo-router/references/plugins.md) ·
[Telemetry](skills/apollo-router/references/telemetry.md) ·
[Troubleshooting](skills/apollo-router/references/troubleshooting.md)
---
### apollo-server
Build GraphQL servers with Apollo Server 4.x, including schemas, resolvers, authentication, and plugins.
**Install:**
```bash
npx skills add apollographql/skills@apollo-server
```
**Use when:**
- Setting up a new Apollo Server project
- Writing resolvers or defining GraphQL schemas
- Implementing authentication or authorization
- Creating plugins or custom data sources
- Troubleshooting Apollo Server errors or performance issues
**Categories covered:**
- Quick start setup (standalone and Express)
- Schema definition and type system
- Resolver patterns and best practices
- Context and authentication
- Plugins and lifecycle hooks
- Data sources and DataLoader
- Error handling and formatting
**Examples:**
- "Create an Apollo Server with user authentication"
- "Write resolvers for my GraphQL schema"
- "Add a custom plugin to log all queries"
**References:**
[SKILL.md](skills/apollo-server/SKILL.md) ·
[Resolvers](skills/apollo-server/references/resolvers.md) ·
[Context & Auth](skills/apollo-server/references/context-and-auth.md) ·
[Plugins](skills/apollo-server/references/plugins.md) ·
[Data Sources](skills/apollo-server/references/data-sources.md) ·
[Error Handling](skills/apollo-server/references/error-handling.md) ·
[Troubleshooting](skills/apollo-server/references/troubleshooting.md)
---
### apollo-client
Build React applications with Apollo Client 4.x for GraphQL data management, caching, and local state.
**Install:**
```bash
npx skills add apollographql/skills@apollo-client
```
**Use when:**
- Setting up Apollo Client in a React project
- Writing GraphQL queries or mutations with hooks
- Configuring caching or cache policies
- Managing local state with reactive variables
- Troubleshooting Apollo Client errors or performance issues
**Categories covered:**
- Quick start setup (install, client, provider, query)
- useQuery and useLazyQuery hooks
- useMutation with optimistic UI
- InMemoryCache and type policies
- Reactive variables and local state
- Error handling and error links
- Performance optimization
**Examples:**
- "Set up Apollo Client in my React app"
- "Implement optimistic UI for my mutation"
- "Configure cache policies for my queries"
**References:**
[SKILL.md](skills/apollo-client/SKILL.md) ·
[Queries](skills/apollo-client/references/queries.md) ·
[Mutations](skills/apollo-client/references/mutations.md) ·
[Caching](skills/apollo-client/references/caching.md) ·
[State Management](skills/apollo-client/references/state-management.md) ·
[Error Handling](skills/apollo-client/references/error-handling.md) ·
[Troubleshooting](skills/apollo-client/references/troubleshooting.md)
---
### apollo-ios
Build Apple-platform applications with Apollo iOS, the strongly-typed GraphQL client for Swift (iOS, macOS, tvOS, watchOS, visionOS).
**Install:**
```bash
npx skills add apollographql/skills@apollo-ios
```
**Use when:**
- Adding Apollo iOS to a Swift Package Manager or Xcode project
- Configuring `apollo-codegen-config.json` and running code generation
- Configuring an `ApolloClient` with auth, interceptors, and caching
- Writing queries, mutations, or subscriptions from SwiftUI views
- Writing tests against generated operation mocks
**Categories covered:**
- SPM installation, product linking (`Apollo` vs `ApolloAPI`), and `apollo-ios-cli` setup
- Code generation config (`apollo-codegen-config.json`) with the canonical `swiftPackage` + `relative` defaults
- Custom scalars (default `String` typealias, when and how to replace it)
- Queries, mutations, watchers, and cache policies with async/await
- Normalized cache, `@typePolicy` cache keys, manual reads/writes
- Interceptor architecture split across HTTP and GraphQL layers (auth token attachment + token refresh + retry)
- Subscriptions over HTTP multipart and WebSocket, with scene-phase pause/resume
- Testing with `ApolloTestSupport` and generated `Mock<Type>` fixtures (enabled lazily when tests need them)
**Examples:**
- "Set up Apollo iOS in a new SwiftUI app"
- "Add an auth token to every GraphQL request"
- "Subscribe to a GraphQL subscription from a SwiftUI view"
**References:**
[SKILL.md](skills/apollo-ios/SKILL.md) ·
[Setup](skills/apollo-ios/references/setup.md) ·
[Codegen](skills/apollo-ios/references/codegen.md) ·
[Custom Scalars](skills/apollo-ios/references/custom-scalars.md) ·
[Operations](skills/apollo-ios/references/operations.md) ·
[Caching](skills/apollo-ios/references/caching.md) ·
[Interceptors](skills/apollo-ios/references/interceptors.md) ·
[Subscriptions](skills/apollo-ios/references/subscriptions.md) ·
[Testing](skills/apollo-ios/references/testing.md)
---
### apollo-kotlin
Build applications with Apollo Kotlin, the GraphQL client library for Android and Kotlin.
**Install:**
```bash
npx skills add apollographql/skills@apollo-kotlin
```
**Use when:**
- Setting up Apollo Kotlin in a Gradle project for Android, Kotlin/JVM, or KMP
- Configuring schema download and codegen for GraphQL services
- Configuring an `ApolloClient` with auth, interceptors, and caching
- Writing queries, mutations, or subscriptions
**Categories covered:**
- Gradle plugin setup and service configuration
- Schema management and code generation
- ApolloClient configuration
- Coroutines and Flow usage patterns
- Normalized cache and cache policies
**Examples:**
- "Set up Apollo Kotlin in my Android app"
- "Configure code generation for multiple GraphQL services"
- "Add normalized caching for offline support"
**References:**
[SKILL.md](skills/apollo-kotlin/SKILL.md) ·
[Setup](skills/apollo-kotlin/references/setup.md) ·
[Operations](skills/apollo-kotlin/references/operations.md) ·
[Caching](skills/apollo-kotlin/references/caching.md) ·
---
### rover
Manage GraphQL schemas and run local supergraph development with Apollo Rover CLI.
**Install:**
```bash
npx skills add apollographql/skills@rover
```
**Use when:**
- Publishing or fetching subgraph schemas to/from GraphOS
- Composing supergraph schemas locally
- Running local supergraph development with rover dev
- Validating schemas with check and lint commands
**Categories covered:**
- Subgraph commands (fetch, publish, check, lint)
- Graph commands (monograph management)
- Supergraph composition
- Local development with rover dev
- Authentication and configuration
**Examples:**
- "Publish my subgraph schema to GraphOS"
- "Run rover dev to test my supergraph locally"
- "Check my schema changes before deploying"
**References:**
[SKILL.md](skills/rover/SKILL.md) ·
[Subgraphs](skills/rover/references/subgraphs.md) ·
[Graphs](skills/rover/references/graphs.md) ·
[Supergraphs](skills/rover/references/supergraphs.md) ·
[Dev](skills/rover/references/dev.md) ·
[Configuration](skills/rover/references/configuration.md)
---
### graphql-schema
Design GraphQL schemas following industry best practices for type design, naming, pagination, errors, and security.
**Install:**
```bash
npx skills add apollographql/skills@graphql-schema
```
**Use when:**
- Designing a new GraphQL schema or API
- Reviewing existing schema for improvements
- Deciding on type structures or nullability
- Implementing pagination or error patterns
- Ensuring security in schema design
**Categories covered:**
- Type design patterns (interfaces, unions, custom scalars)
- Naming conventions for types, fields, and arguments
- Cursor-based pagination (Connection pattern)
- Error modeling and result types
- Security best practices (depth limiting, complexity, authorization)
**Examples:**
- "Design a GraphQL schema for my e-commerce API"
- "Review my schema for best practices"
- "Add cursor-based pagination to my queries"
**References:**
[SKILL.md](skills/graphql-schema/SKILL.md) ·
[Types](skills/graphql-schema/references/types.md) ·
[Naming](skills/graphql-schema/references/naming.md) ·
[Pagination](skills/graphql-schema/references/pagination.md) ·
[Errors](skills/graphql-schema/references/errors.md) ·
[Security](skills/graphql-schema/references/security.md)
---
### graphql-operations
Write GraphQL operations (queries, mutations, fragments) following best practices for client-side development.
**Install:**
```bash
npx skills add apollographql/skills@graphql-operations
```
**Use when:**
- Writing GraphQL queries or mutations
- Organizing operations with fragments
- Optimizing data fetching patterns
- Setting up type generation or linting
- Reviewing operations for efficiency
**Categories covered:**
- Query patterns and optimization
- Mutation patterns and error handling
- Fragment organization and colocation
- Variable usage and types
- Tooling (GraphQL Code Generator, ESLint, IDE extensions)
**Examples:**
- "Write a query with pagination"
- "Organize my operations with fragments"
- "Set up GraphQL Code Generator for type safety"
**References:**
[SKILL.md](skills/graphql-operations/SKILL.md) ·
[Queries](skills/graphql-operations/references/queries.md) ·
[Mutations](skills/graphql-operations/references/mutations.md) ·
[Fragments](skills/graphql-operations/references/fragments.md) ·
[Variables](skills/graphql-operations/references/variables.md) ·
[Tooling](skills/graphql-operations/references/tooling.md)
---
### rust-best-practices
Write idiomatic Rust code following Apollo GraphQL's best practices handbook.
**Install:**
```bash
npx skills add apollographql/skills@rust-best-practices
```
**Use when:**
- Writing new Rust code or functions
- Reviewing or refactoring existing Rust code
- Deciding between borrowing vs cloning or ownership patterns
- Implementing error handling with Result types
- Optimizing Rust code for performance
- Writing tests or documentation for Rust projects
**Categories covered:**
- Coding style and idioms (borrowing, Option/Result, iterators)
- Clippy and linting discipline
- Performance optimization and profiling
- Error handling with thiserror and anyhow
- Testing strategies and snapshot testing
- Generics, static and dynamic dispatch
- Type state pattern for compile-time safety
- Documentation best practices
- Pointer types and thread safety
**Examples:**
- "Review this Rust code for best practices"
- "Help me decide between cloning and borrowing here"
- "Add proper error handling to this function"
**References:**
[SKILL.md](skills/rust-best-practices/SKILL.md) ·
[Style](skills/rust-best-practices/references/style.md) ·
[Errors](skills/rust-best-practices/references/errors.md) ·
[Performance](skills/rust-best-practices/references/performance.md) ·
[Testing](skills/rust-best-practices/references/testing.md) ·
[Advanced](skills/rust-best-practices/references/advanced.md)
---
### skill-creator
Guide for creating effective skills for Apollo GraphQL and GraphQL development.
**Install:**
```bash
npx skills add apollographql/skills@skill-creator
```
**Use when:**
- Creating a new skill for this repository
- Updating an existing skill's structure or content
- Learning skill best practices and patterns
- Writing SKILL.md files or reference documentation
**Categories covered:**
- SKILL.md format and frontmatter fields
- Directory structure and reference files
- Description writing for agent activation triggers
- Progressive disclosure and context optimization
- Apollo Voice writing style guidelines
- Validation checklist for new skills
**Examples:**
- "Create a new skill for Apollo Federation"
- "Help me write a SKILL.md for my custom skill"
- "Review my skill structure for best practices"
**References:**
[SKILL.md](skills/skill-creator/SKILL.md) ·
[Apollo Skills](skills/skill-creator/references/apollo-skills.md)
---
## Usage
Skills activate automatically once installed. The agent uses them when relevant tasks are detected.
You can also explicitly invoke a skill depending on your tool:
| Tool | Automatic | Explicit Invocation |
| -------------- | --------- | ------------------------------------------------------- |
| Claude Code | Yes | Slash command (e.g., `/graphql-schema` or `/apollo-skills:graphql-schema` via plugin) |
| GitHub Copilot | Yes | `/agent` for custom agents, `@github` for GitHub skills |
| Cursor | Yes | Rules matched by file patterns (no direct invocation) |
| Windsurf | Yes | Slash command for workflows (e.g., `/workflow-name`) |
## Skill Structure
Each skill contains:
- `SKILL.md` - Instructions for the agent (required)
- `references/` - Supporting documentation (optional)
## Resources
- [Apollo Client Documentation](https://www.apollographql.com/docs/react/)
- [Apollo Server Documentation](https://www.apollographql.com/docs/apollo-server/)
- [Apollo Connectors Documentation](https://www.apollographql.com/docs/graphos/schema-design/connectors/)
- [Apollo Federation Documentation](https://www.apollographql.com/docs/graphos/schema-design/federated-schemas/)
- [Apollo MCP Server](https://www.apollographql.com/docs/apollo-mcp-server/)
- [Apollo iOS Documentation](https://www.apollographql.com/docs/ios/)
- [Rover CLI Documentation](https://www.apollographql.com/docs/rover/)
- [Rust Best Practices Handbook](https://github.com/apollographql/rust-best-practices)
## Disclaimer
The code in this repository is experimental and for reference purposes only. Community feedback is welcome but this project is not officially supported in the same way that repositories in the official [Apollo GraphQL GitHub organization](https://github.com/apollographql) are. If you need help you can file an issue on this repository, [contact Apollo](https://www.apollographql.com/contact-sales) to talk to an expert, or create a ticket directly in Apollo Studio.
## skills/apollo-client/SKILL.md
---
name: apollo-client
description: >
Guide for building React applications with Apollo Client 4.x. Use this skill when:
(1) setting up Apollo Client in a React project,
(2) writing GraphQL queries or mutations with hooks,
(3) configuring caching or cache policies,
(4) managing local state with reactive variables,
(5) troubleshooting Apollo Client errors or performance issues.
license: MIT
compatibility: React 18+, React 19 (Suspense/RSC). Works with Next.js, Vite, CRA, and other React frameworks.
metadata:
author: apollographql
version: "1.0.0"
allowed-tools: Bash(npm:*) Bash(npx:*) Bash(node:*) Read Write Edit Glob Grep
---
# Apollo Client 4.x Guide
Apollo Client is a comprehensive state management library for JavaScript that enables you to manage both local and remote data with GraphQL. Version 4.x brings improved caching, better TypeScript support, and React 19 compatibility.
## Integration Guides
Choose the integration guide that matches your application setup:
- **[Client-Side Apps](references/integration-client.md)** - For client-side React applications without SSR (Vite, Create React App, etc.)
- **[Next.js App Router](references/integration-nextjs.md)** - For Next.js applications using the App Router with React Server Components
- **[React Router Framework Mode](references/integration-react-router.md)** - For React Router 7 applications with streaming SSR
- **[TanStack Start](references/integration-tanstack-start.md)** - For TanStack Start applications with modern routing
Each guide includes installation steps, configuration, and framework-specific patterns optimized for that environment.
## Quick Reference
### Basic Query
```tsx
import { gql } from "@apollo/client";
import { useQuery } from "@apollo/client/react";
const GET_USER = gql`
query GetUser($id: ID!) {
user(id: $id) {
id
name
}
}
`;
function UserProfile({ userId }: { userId: string }) {
const { loading, error, data, dataState } = useQuery(GET_USER, {
variables: { id: userId },
});
if (loading) return <p>Loading...</p>;
if (error) return <p>Error: {error.message}</p>;
// TypeScript note: for stricter type narrowing, you can also check `dataState === "complete"` before accessing data
return <div>{data?.user.name}</div>;
}
```
### Basic Mutation
```tsx
import { gql } from "@apollo/client";
import { useMutation } from "@apollo/client/react";
const CREATE_USER = gql`
mutation CreateUser($input: CreateUserInput!) {
createUser(input: $input) {
id
name
}
}
`;
function CreateUserForm() {
const [createUser, { loading, error }] = useMutation(CREATE_USER);
const handleSubmit = async (name: string) => {
await createUser({ variables: { input: { name } } });
};
return <button onClick={() => handleSubmit("John")}>Create User</button>;
}
```
### Suspense Query
```tsx
import { Suspense } from "react";
import { useSuspenseQuery } from "@apollo/client/react";
function UserProfile({ userId }: { userId: string }) {
const { data } = useSuspenseQuery(GET_USER, {
variables: { id: userId },
});
return <div>{data.user.name}</div>;
}
function App() {
return (
<Suspense fallback={<p>Loading user...</p>}>
<UserProfile userId="1" />
</Suspense>
);
}
```
## Reference Files
Detailed documentation for specific topics:
- [TypeScript Code Generation](references/typescript-codegen.md) - GraphQL Code Generator setup for type-safe operations
- [Queries](references/queries.md) - useQuery, useLazyQuery, polling, refetching
- [Suspense Hooks](references/suspense-hooks.md) - useSuspenseQuery, useBackgroundQuery, useReadQuery, useLoadableQuery
- [Mutations](references/mutations.md) - useMutation, optimistic UI, cache updates
- [Fragments](references/fragments.md) - Fragment colocation, useFragment, useSuspenseFragment, data masking
- [Caching](references/caching.md) - InMemoryCache, typePolicies, cache manipulation
- [State Management](references/state-management.md) - Reactive variables, local state
- [Error Handling](references/error-handling.md) - Error policies, error links, retries
- [Troubleshooting](references/troubleshooting.md) - Common issues and solutions
## Key Rules
### Query Best Practices
- **Each page should generally only have one query, composed from colocated fragments.** Use `useFragment` or `useSuspenseFragment` in all non-page-components. Use `@defer` to allow slow fields below the fold to stream in later and avoid blocking the page load.
- **Fragments are for colocation, not reuse.** Each fragment should describe exactly the data needs of a specific component, not be shared across components for common fields. See [Fragments reference](references/fragments.md) for details on fragment colocation and data masking.
- Always handle `loading` and `error` states in UI when using non-suspenseful hooks (`useQuery`, `useLazyQuery`). When using Suspense hooks (`useSuspenseQuery`, `useBackgroundQuery`), React handles this through `<Suspense>` boundaries and error boundaries.
- Use `fetchPolicy` to control cache behavior per query
- Use the TypeScript type server to look up documentation for functions and options (Apollo Client has extensive docblocks)
### Mutation Best Practices
- **If the schema permits, mutation return values should return everything necessary to update the cache.** Neither manual updates nor refetching should be necessary.
- If the mutation response is insufficient, carefully weigh manual cache manipulation vs refetching. Manual updates risk missing server logic. Consider optimistic updates with a granular refetch if needed.
- Handle errors gracefully in the UI
- Use `refetchQueries` sparingly (prefer letting the cache update automatically)
### Caching Best Practices
- Configure `keyFields` for types without `id` field
- Disable normalization by setting `keyFields: false` for types that don't include an identifier and are meant to group related fields under the parent
- Use `typePolicies` for pagination and computed fields
- Understand cache normalization to debug issues
- **Enable [data masking](references/fragments.md#data-masking) for all new applications** - it prevents components from accessing fragment data they don't own, enforcing proper data boundaries and preventing over-rendering
### Performance
- Avoid over-fetching with proper field selection
- Configure appropriate `fetchPolicy` per use case
- Use `@defer` for incremental delivery of deferred query parts, and `@stream` for streaming list fields (`@stream` available in Apollo Client 4.1+)
- **Prefer Suspense hooks (`useSuspenseQuery`, `useBackgroundQuery`) in modern applications** for better loading state handling and code simplicity
## Ground Rules
- ALWAYS use Apollo Client 4.x patterns (not v3 or earlier)
- ALWAYS wrap your app with `ApolloProvider`
- ALWAYS handle loading and error states when using non-suspenseful hooks
- PREFER Suspense hooks (`useSuspenseQuery`, `useBackgroundQuery`) in modern applications for better DX
- NEVER store Apollo Client in React state (use module-level or context)
- PREFER `cache-first` for read-heavy data, `network-only` for real-time data
- USE TypeScript for better type safety with GraphQL
- IMPLEMENT proper cache updates instead of refetching entire queries
- ADVISE the human steering you to look into Apollo DevTools when collaboratively debugging Apollo Client issues
## skills/apollo-connectors/SKILL.md
---
name: apollo-connectors
description: >
Guide for integrating REST APIs into GraphQL supergraphs using Apollo Connectors
with @source and @connect directives. Use this skill when the user:
(1) mentions "connectors", "Apollo Connectors", or "REST Connector",
(2) wants to integrate a REST API into GraphQL,
(3) references @source or @connect directives,
(4) works with files containing "# Note to AI Friends: This is an Apollo Connectors schema".
license: MIT
compatibility: Requires rover CLI installed. Works with Claude Code and similar AI coding assistants.
metadata:
author: apollographql
version: "1.0.0"
allowed-tools: Bash(rover:*) Read Write Edit Glob Grep
---
# Apollo Connectors Schema Assistant
## MCP Tools
If GraphOS MCP Tools are available, use them:
- **connectors-spec**: Fetch the complete Connectors specification before starting any connector work
- **apollo_docs_search**: Search for relevant documentation
- **apollo_docs_read**: Read specific documentation pages by slug
**Documentation paths by topic:**
- Requests: `/graphos/connectors/requests/url`, `/headers`, `/body`, `/batching`
- Responses: `/graphos/connectors/responses/fields`, `/error-handling`
- Mapping: `/graphos/connectors/mapping`, `/arrays`, `/enums`, `/literals`
- Entities: `/graphos/connectors/entities`, `/patterns`
## Process
Follow this 5-step process. **DO NOT skip any steps.**
### Step 1: Research
- [ ] Understand the API being called and the structure of responses
- [ ] Ask the user for example API responses if not provided
- [ ] Fetch relevant documentation from MCP tools or reference files
- [ ] DO NOT write any code until research is complete
### Step 2: Implement
- [ ] Create the schema using the template below
- [ ] Follow the grammar, methods, and variables in the reference files
- [ ] Ask clarifying questions if unsure about requirements
### Step 3: Validate (Compose)
- [ ] Run `rover supergraph compose --config ./supergraph.yaml`
- [ ] Fix any composition errors before proceeding
### Step 4: Execute
- [ ] Run `rover connector run --schema <file> -c "<Type.field>" -v "{}"`
- [ ] Verify the connector executes correctly
### Step 5: Test
- [ ] Create or update test files under `/tests/`
- [ ] Run `rover connector test`
- [ ] Ensure full test coverage for each connector
## Schema Template
```graphql
# Note to AI Friends: This is an Apollo Connectors schema. You should use your connectors-spec MCP tool if you have it available before editing this file.
extend schema
@link(url: "https://specs.apollo.dev/federation/v2.12")
@link(url: "https://specs.apollo.dev/connect/v0.3", import: ["@source", "@connect"])
@source(name: "api_name", http: { baseURL: "https://api.example.com" })
type Query {
example(id: ID!): Example
@connect(
source: "api_name"
http: { GET: "/example/{$args.id}" }
selection: """
id
name
"""
)
}
type Example {
id: ID!
name: String
}
```
**Version Requirements:** Always use `federation/v2.12` and `connect/v0.3` unless specified otherwise.
## Reference Files
Before implementing connectors, read the relevant reference files:
- [Grammar](references/grammar.md) - Selection mapping EBNF syntax
- [Methods](references/methods.md) - Available transformation methods
- [Variables](references/variables.md) - Available mapping variables
- [Entities](references/entities.md) - Entity patterns and batching
- [Validation](references/validation.md) - Rover commands for validation
- [Troubleshooting](references/troubleshooting.md) - Common errors and solutions
## Key Rules
### Selection Mapping
- Prefer sub-selections over `->map` for cleaner mappings
- Do NOT use `$` when selecting fields directly from root
- Field aliasing: `newName: originalField` (only when renaming)
- Sub-selection: `fieldName { ... }` (to map nested content)
```
# DO - Direct sub-selection for arrays
$.results {
firstName: name.first
lastName: name.last
}
# DO NOT - Unnecessary root $
$ {
id
name
}
# DO - Direct field selection
id
name
```
### Entities
- Add `@connect` on a type to make it an entity (no `@key` needed)
- Create entity stubs in parent selections: `user: { id: userId }`
- When you see an ID field (e.g., `productId`), create an entity relationship
- Each entity should have ONE authoritative subgraph with `@connect`
### Literal Values
Use `$()` wrapper for literal values in mappings:
```
$(1) # number
$(true) # boolean
$("hello") # string
$({"a": "b"}) # object
# In body
body: "$({ a: $args.a })" # CORRECT
body: "{ a: $args.a }" # WRONG - will not compose
```
### Headers
```graphql
http: {
GET: "/api"
headers: [
{ name: "Authorization", value: "Bearer {$env.API_KEY}" },
{ name: "X-Forwarded", from: "x-client" }
]
}
```
### Batching
Convert N+1 patterns using `$batch`:
```graphql
type Product @connect(
source: "api"
http: {
POST: "/batch"
body: "ids: $batch.id"
}
selection: "id name"
) {
id: ID!
name: String
}
```
## Ground Rules
- NEVER make up syntax or directive values not in this specification
- NEVER use `--elv2-license accept` (for humans only)
- ALWAYS ask for example API responses before writing code
- ALWAYS validate with `rover supergraph compose` after changes
- ALWAYS create entity relationships when you see ID fields
- Prefer `$env` over `$config` for environment variables
- Use `rover dev` for running Apollo Router locally
## skills/apollo-federation/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`:
```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
## skills/apollo-ios/SKILL.md
---
name: apollo-ios
description: >
Guide for building Apple-platform applications with Apollo iOS, the strongly-typed GraphQL client for Swift. Use this skill when:
(1) adding Apollo iOS to a Swift Package Manager or Xcode project,
(2) configuring `apollo-codegen-config.json` and running code