apollo-server
Guides building GraphQL servers using Apollo Server 5.x with resolvers, schemas, and integrations into Express, Fastify, or standalone deployments.
Identity proven by a skills index on apollographql.com
- Agents
- Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, OpenCode, claude.ai and API
- License
- MIT (permissive)
- Pin
- 5f02fcfpinned Oct 9, 2026
- Context cost
- about 1,600 tokenswhen the skill loads
- GitHub stars
- 117on apollographql/skills
- Scripts
- None found
What it does
“Guide for building GraphQL servers with Apollo Server 5.x. Use this skill when: (1) setting up a new Apollo Server project, (2) writing resolvers or defining GraphQL schemas, (3) implementing authentication or authorization, (4) creating plugins or custom data sources, (5) troubleshooting Apollo Server errors or performance issues.”
Generated summary from the skill's own text
Guides building GraphQL servers using Apollo Server 5.x with resolvers, schemas, and integrations into Express, Fastify, or standalone deployments. Covers authentication, plugins, data sources, error handling, and troubleshooting for Node.js v20+ and TypeScript 4.7+ projects.
When to use it
- Setting up a new Apollo Server project from scratch
- Writing GraphQL schemas and resolver implementations
- Adding authentication or authorization logic to GraphQL APIs
- Integrating Apollo Server with Express, Fastify, or serverless frameworks
When not to
- Upgrading from Apollo Server v4 or earlier versions
- Building non-GraphQL REST or other API types
Install
These commands install from the publisher's repository and need no account.
skills CLI
npx skills add apollographql/skills --skill apollo-serverInstalls from the repository's default branch, which may have changed since the commit we checked.
GitHub CLI 2.90 or later
gh skill install apollographql/skills apollo-server@5f02fcfcebec678e2e55777b639e32346622a963Installs the commit we checked (5f02fcf).
Copy by hand
Download the folder at 5f02fcf and put it in .claude/skills/apollo-server for Claude Code and in .agents/skills/apollo-server for Codex, Cursor, Gemini CLI, GitHub Copilot and OpenCode.
Claude Code plugin
/plugin install apollo-skills@claude-plugins-officialThe publisher's plugin in Claude's official marketplace. It may hold more than this skill, and we have not pinned it.
Copy for your agent
A prompt for any coding agent. It installs this skill from GitHub at the pinned commit, copies the files as they are, and runs nothing unless you ask.
Prompt
Install the agent skill "apollo-server" by Apollo GraphQL. Source, pinned to commit 5f02fcfcebec678e2e55777b639e32346622a963: https://github.com/apollographql/skills/tree/5f02fcfcebec678e2e55777b639e32346622a963/skills/apollo-server 1. Download that folder at exactly this commit. Do not use the default branch. 2. Copy every file unchanged, keeping the folder structure, into .claude/skills/apollo-server/ for Claude Code and .agents/skills/apollo-server/ for Codex, Cursor, Gemini CLI, GitHub Copilot and OpenCode. Create the folders if they do not exist. 3. Do not edit the files, and do not run any script in the folder unless I ask you to. 4. When you are done, list the files you copied and where you put them. Listing and checks: https://www.agentnative.dev/skills/apollo-graphql/apollo-server
SKILL.md at the pin
---
name: apollo-server
description: >
Guide for building GraphQL servers with Apollo Server 5.x. Use this skill when:
(1) setting up a new Apollo Server project,
(2) writing resolvers or defining GraphQL schemas,
(3) implementing authentication or authorization,
(4) creating plugins or custom data sources,
(5) troubleshooting Apollo Server errors or performance issues.
license: MIT
compatibility: Node.js v20+, TypeScript 4.7+. Works with Express v4/v5, standalone, Fastify, and serverless.
metadata:
author: apollographql
version: "1.0.0"
allowed-tools: Bash(npm:*) Bash(npx:*) Bash(node:*) Read Write Edit Glob Grep
---
# Apollo Server 5.x Guide
Apollo Server is an open-source GraphQL server that works with any GraphQL schema. Apollo Server 5 is framework-agnostic and runs standalone or integrates with Express, Fastify, and serverless environments.
## Quick Start
### Step 1: Install
```bash
npm install @apollo/server graphql
```
For Express integration:
```bash
npm install @apollo/server @as-integrations/express5 express graphql cors
```
### Step 2: Define Schema
```typescript
const typeDefs = `#graphql
type Book {
title: String
author: String
}
type Query {
books: [Book]
}
`;
```
### Step 3: Write Resolvers
```typescript
const resolvers = {
Query: {
books: () => [
{ title: "The Great Gatsby", author: "F. Scott Fitzgerald" },
{ title: "1984", author: "George Orwell" },
],
},
};
```
### Step 4: Start Server
**Standalone (Recommended for prototyping):**
The standalone server is great for prototyping, but for production services, we recommend integrating Apollo Server with a more fully-featured web framework such as Express, Koa, or Fastify. Swapping from the standalone server to a web framework later is straightforward.
```typescript
import { ApolloServer } from "@apollo/server";
import { startStandaloneServer } from "@apollo/server/standalone";
const server = new ApolloServer({ typeDefs, resolvers });
const { url } = await startStandaloneServer(server, {
listen: { port: 4000 },
});
console.log(`Server ready at ${url}`);
```
**Express:**
```typescript
import { ApolloServer } from "@apollo/server";
import { expressMiddleware } from "@as-integrations/express5";
import { ApolloServerPluginDrainHttpServer } from "@apollo/server/plugin/drainHttpServer";
import express from "express";
import http from "http";
import cors from "cors";
const app = express();
const httpServer = http.createServer(app);
const server = new ApolloServer({
typeDefs,
resolvers,
plugins: [ApolloServerPluginDrainHttpServer({ httpServer })],
});
await server.start();
app.use(
"/graphql",
cors(),
express.json(),
expressMiddleware(server, {
context: async ({ req }) => ({ token: req.headers.authorization }),
}),
);
await new Promise<void>((resolve) => httpServer.listen({ port: 4000 }, resolve));
console.log("Server ready at http://localhost:4000/graphql");
```
## Schema Definition
### Scalar Types
- `Int` - 32-bit integer
- `Float` - Double-precision floating-point
- `String` - UTF-8 string
- `Boolean` - true/false
- `ID` - Unique identifier (serialized as String)
### Type Definitions
```graphql
type User {
id: ID!
name: String!
email: String
posts: [Post!]!
}
type Post {
id: ID!
title: String!
content: String
author: User!
}
input CreatePostInput {
title: String!
content: String
}
type Query {
user(id: ID!): User
users: [User!]!
}
type Mutation {
createPost(input: CreatePostInput!): Post!
}
```
### Enums and Interfaces
```graphql
enum Status {
DRAFT
PUBLISHED
ARCHIVED
}
interface Node {
id: ID!
}
type Article implements Node {
id: ID!
title: String!
}
```
## Resolvers Overview
Resolvers follow the signature: `(parent, args, contextValue, info)`
- **parent**: Result from parent resolver (root resolvers receive undefined)
- **args**: Arguments passed to the field
- **contextValue**: Shared context object (auth, dataSources, etc.)
- **info**: Field-specific info and schema details (rarely used)
```typescript
const resolvers = {
Query: {
user: async (_, { id }, { dataSources }) => {
return dataSources.usersAPI.getUser(id);
},
},
User: {
posts: async (parent, _, { dataSources }) => {
return dataSources.postsAPI.getPostsByAuthor(parent.id);
},
},
Mutation: {
createPost: async (_, { input }, { dataSources, user }) => {
if (!user) throw new GraphQLError("Not authenticated");
return dataSources.postsAPI.create({ ...input, authorId: user.id });
},
},
};
```
## Context Setup
Context is created per-request and passed to all resolvers.
```typescript
interface MyContext {
token?: string;
user?: User;
dataSources: {
usersAPI: UsersDataSource;
postsAPI: PostsDataSource;
};
}
const server = new ApolloServer<MyContext>({
typeDefs,
resolvers,
});
// Standalone
const { url } = await startStandaloneServer(server, {
context: async ({ req }) => ({
token: req.headers.authorization || "",
user: await getUser(req.headers.authorization || ""),
dataSources: {
usersAPI: new UsersDataSource(),
postsAPI: new PostsDataSource(),
},
}),
});
// Express middleware
expressMiddleware(server, {
context: async ({ req, res }) => ({
token: req.headers.authorization,
user: await getUser(req.headers.authorization),
dataSources: {
usersAPI: new UsersDataSource(),
postsAPI: new PostsDataSource(),
},
}),
});
```
## Reference Files
Detailed documentation for specific topics:
- [Resolvers](references/resolvers.md) - Resolver patterns and best practices
- [Context and Auth](references/context-and-auth.md) - Authentication and authorization
- [Plugins](references/plugins.md) - Server and request lifecycle hooks
- [Data Sources](references/data-sources.md) - RESTDataSource and DataLoader
- [Error Handling](references/error-handling.md) - GraphQLError and error formatting
- [Troubleshooting](references/troubleshooting.md) - Common issues and solutions
## Key Rules
### Schema Design
- Use **!** (non-null) for fields that always have values
- Prefer input types for mutations over inline arguments
- Use interfaces for polymorphic types
- Keep schema descriptions for documentation
### Resolver Best Practices
- Keep resolvers thin - delegate to services/data sources
- Always handle errors explicitly
- Use DataLoader for batching related queries
- Return partial data when possible (GraphQL's strength)
### Performance
- Use `@defer` and `@stream` for large responses
- Implement DataLoader to solve N+1 queries
- Consider persisted queries for production
- Use caching headers and CDN where appropriate
## Ground Rules
- ALWAYS use Apollo Server 5.x patterns (not v4 or earlier)
- ALWAYS type your context with TypeScript generics
- ALWAYS use `GraphQLError` from `graphql` package for errors
- NEVER expose stack traces in production errors
- PREFER `startStandaloneServer` for prototyping only
- USE an integration with a server framework like Express, Koa, Fastify, Next, etc. for production apps
- IMPLEMENT authentication in context, authorization in resolvers
From apollographql/skills at 5f02fcf, shown as plain text under its license: MIT (permissive). The license text is in skills/apollo-server/SKILL.md.
View SKILL.md on GitHub at 5f02fcfFiles
- SKILL.md7.2 KB · 7e56911da905
- references/
- context-and-auth.md10.0 KB · 25058b58d01b
- data-sources.md9.2 KB · f109cb30e623
- error-handling.md10 KB · b2837f6d4c0e
- plugins.md11 KB · c818180b4cb5
- resolvers.md8.1 KB · 55a33184bb8e
- troubleshooting.md10 KB · 7a5c447b8694
7 files, 66 KB in total. Each file has a sha256 in the pin's manifest; the first 12 characters are shown.
Skill folder on GitHub at 5f02fcfMore from Apollo GraphQL
apollo-client
This skill guides building React applications with Apollo Client 4.x for managing GraphQL queries, mutations, and state.
Claude Code, Codex, Cursor +4 · about 1.7K tokens · pinned 6 days ago
apollo-connectors
This skill helps integrate REST APIs into GraphQL supergraphs using Apollo Connectors with @source and @connect directives.
Claude Code, Codex, Cursor +4 · about 1.6K tokens · pinned 6 days ago
apollo-federation
This skill guides agents in authoring Apollo Federation subgraph schemas using Federation 2.x directives like @key, @shareable, @external, and @requires.
Claude Code, Codex, Cursor +4 · about 830 tokens · pinned 6 days ago
apollo-ios
This skill guides building GraphQL-powered Apple apps with Apollo iOS, a strongly-typed Swift client.
Contains scripts
Claude Code · about 1.8K tokens · pinned 6 days ago
apollo-kotlin
This skill guides building GraphQL applications with Apollo Kotlin, a strongly typed client library for Android, JVM, and Kotlin Multiplatform projects.
Contains scripts
Claude Code, Codex, Cursor +3 · about 370 tokens · pinned 6 days ago
apollo-router
Generates version-correct Apollo Router configuration (v1.x or v2.x) for federated GraphQL supergraphs.
Claude Code, Codex, Cursor +4 · about 5.1K tokens · pinned 6 days ago
Related in Backend and APIs
shopify-admin
This skill is deprecated and has been replaced by the shopify skill.
by ShopifyOfficial publisher
Claude Code, Codex, Cursor +4 · about 66 tokens · pinned 6 days ago
shopify-customer
This skill is deprecated and no longer maintained.
by ShopifyOfficial publisher
Claude Code, Codex, Cursor +4 · about 69 tokens · pinned 6 days ago
commerce-app-api-mesh
This skill scaffolds or updates an Adobe API Mesh configuration to extend a Commerce GraphQL schema with new fields resolved by runtime actions or external…
by Adobe, Inc.Official publisher
Claude Code, Codex, Cursor +4 · about 2.1K tokens · pinned 6 days ago
graphql-schema
This skill guides agents through designing and modifying GraphQL schemas following industry best practices.
by Apollo GraphQLOfficial publisher
Claude Code, Codex, Cursor +4 · about 1.1K tokens · pinned 6 days ago
build-zoom-rest-api-app
This skill provides comprehensive reference documentation and examples for building server-side integrations with the Zoom REST API, covering 600+ endpoints…
by ZoomOfficial publisher
Claude Code, Codex, Cursor +3 · about 6.7K tokens · pinned 6 days ago
api-and-interface-design
This skill guides design of stable, well-documented APIs and interfaces for REST endpoints, GraphQL schemas, module boundaries, and component contracts.
by addyosmaniCommunity
Claude Code, Codex, Cursor +4 · about 3.6K tokens · pinned 6 days ago