Expertise·API Development·v1.0.0

Apollo Server

Guide for building GraphQL servers with Apollo Server 5.x: resolvers, schema definitions, authentication, plugins, data sources and…

You say
Install this skill Read the source first Free Written by apollographql · unverified publisher
Context cost
16.5k tokensestimated from the bundle, loaded when it triggers
Bundle
7 files · 66.0 kBtext throughout, nothing executable
Licence
MITfree to use
Last change
v1.0.0
Servers it uses
Noneruns standalone

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.

Installed, it changes the agent in these ways.

What this skill changes about the agent is not written down here yet. The listing was collected from its source, and the description is in its own SKILL.md.

Expertise

Domain judgement the base model does not have.

graphqlapolloservernodejs
Filed under

API Development

The skill itself

This is the whole product. A skill is instructions the model reads, so there is nothing behind the listing you cannot see first — the front matter loads with every session, and the body below it loads when the skill triggers.

SKILL.md7.2 kB · 295 lines
--- 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 ---
18# Apollo Server 5.x Guide
19
20Apollo 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.
21
22## Quick Start
23
24### Step 1: Install
25
26```bash
27npm install @apollo/server graphql
28```
29
30For Express integration:
31
32```bash
33npm install @apollo/server @as-integrations/express5 express graphql cors
34```
35
36### Step 2: Define Schema
37
38```typescript
39const typeDefs = `#graphql
40 type Book {
41 title: String
42 author: String
43 }
44
45 type Query {
46 books: [Book]
47 }
48`;
49```
50
51### Step 3: Write Resolvers
52
53```typescript
54const resolvers = {
55 Query: {
56 books: () => [
57 { title: "The Great Gatsby", author: "F. Scott Fitzgerald" },
58 { title: "1984", author: "George Orwell" },
59 ],
60 },
61};
62```
63
64### Step 4: Start Server
65
66**Standalone (Recommended for prototyping):**
67
68The 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.
69
70```typescript
71import { ApolloServer } from "@apollo/server";
72import { startStandaloneServer } from "@apollo/server/standalone";
73
74const server = new ApolloServer({ typeDefs, resolvers });
75
76const { url } = await startStandaloneServer(server, {
77 listen: { port: 4000 },
78});
79
80console.log(Server ready at ${url});
81```
82
83**Express:**
84
85```typescript
86import { ApolloServer } from "@apollo/server";
87import { expressMiddleware } from "@as-integrations/express5";
88import { ApolloServerPluginDrainHttpServer } from "@apollo/server/plugin/drainHttpServer";
89import express from "express";
90import http from "http";
91import cors from "cors";
92
93const app = express();
94const httpServer = http.createServer(app);
95
96const server = new ApolloServer({
97 typeDefs,
98 resolvers,
99 plugins: [ApolloServerPluginDrainHttpServer({ httpServer })],
100});
101
102await server.start();
103
104app.use(
105 "/graphql",
106 cors(),
107 express.json(),
108 expressMiddleware(server, {
109 context: async ({ req }) => ({ token: req.headers.authorization }),
110 }),
111);
112
113await new Promise<void>((resolve) => httpServer.listen({ port: 4000 }, resolve));
114console.log("Server ready at http://localhost:4000/graphql");
115```
116
117## Schema Definition
118
119### Scalar Types
120
121- Int - 32-bit integer
122- Float - Double-precision floating-point
123- String - UTF-8 string
124- Boolean - true/false
125- ID - Unique identifier (serialized as String)
126
127### Type Definitions
128
129```graphql
130type User {
131 id: ID!
132 name: String!
133 email: String
134 posts: [Post!]!
135}
136
137type Post {
138 id: ID!
139 title: String!
140 content: String
141 author: User!
142}
143
144input CreatePostInput {
145 title: String!
146 content: String
147}
148
149type Query {
150 user(id: ID!): User
151 users: [User!]!
152}
153
154type Mutation {
155 createPost(input: CreatePostInput!): Post!
156}
157```
158
159### Enums and Interfaces
160
161```graphql
162enum Status {
163 DRAFT
164 PUBLISHED
165 ARCHIVED
166}
167
168interface Node {
169 id: ID!
170}
171
172type Article implements Node {
173 id: ID!
174 title: String!
175}
176```
177
178## Resolvers Overview
179
180Resolvers follow the signature: (parent, args, contextValue, info)
181
182- **parent**: Result from parent resolver (root resolvers receive undefined)
183- **args**: Arguments passed to the field
184- **contextValue**: Shared context object (auth, dataSources, etc.)
185- **info**: Field-specific info and schema details (rarely used)
186
187```typescript
188const resolvers = {
189 Query: {
190 user: async (_, { id }, { dataSources }) => {
191 return dataSources.usersAPI.getUser(id);
192 },
193 },
194 User: {
195 posts: async (parent, _, { dataSources }) => {
196 return dataSources.postsAPI.getPostsByAuthor(parent.id);
197 },
198 },
199 Mutation: {
200 createPost: async (_, { input }, { dataSources, user }) => {
201 if (!user) throw new GraphQLError("Not authenticated");
202 return dataSources.postsAPI.create({ ...input, authorId: user.id });
203 },
204 },
205};
206```
207
208## Context Setup
209
210Context is created per-request and passed to all resolvers.
211
212```typescript
213interface MyContext {
214 token?: string;
215 user?: User;
216 dataSources: {
217 usersAPI: UsersDataSource;
218 postsAPI: PostsDataSource;
219 };
220}
221
222const server = new ApolloServer<MyContext>({
223 typeDefs,
224 resolvers,
225});
226
227// Standalone
228const { url } = await startStandaloneServer(server, {
229 context: async ({ req }) => ({
230 token: req.headers.authorization || "",
231 user: await getUser(req.headers.authorization || ""),
232 dataSources: {
233 usersAPI: new UsersDataSource(),
234 postsAPI: new PostsDataSource(),
235 },
236 }),
237});
238
239// Express middleware
240expressMiddleware(server, {
241 context: async ({ req, res }) => ({
242 token: req.headers.authorization,
243 user: await getUser(req.headers.authorization),
244 dataSources: {
245 usersAPI: new UsersDataSource(),
246 postsAPI: new PostsDataSource(),
247 },
248 }),
249});
250```
251
252## Reference Files
253
254Detailed documentation for specific topics:
255
256- [Resolvers](references/resolvers.md) - Resolver patterns and best practices
257- [Context and Auth](references/context-and-auth.md) - Authentication and authorization
258- [Plugins](references/plugins.md) - Server and request lifecycle hooks
259- [Data Sources](references/data-sources.md) - RESTDataSource and DataLoader
260- [Error Handling](references/error-handling.md) - GraphQLError and error formatting
261- [Troubleshooting](references/troubleshooting.md) - Common issues and solutions
262
263## Key Rules
264
265### Schema Design
266
267- Use **!** (non-null) for fields that always have values
268- Prefer input types for mutations over inline arguments
269- Use interfaces for polymorphic types
270- Keep schema descriptions for documentation
271
272### Resolver Best Practices
273
274- Keep resolvers thin - delegate to services/data sources
275- Always handle errors explicitly
276- Use DataLoader for batching related queries
277- Return partial data when possible (GraphQL's strength)
278
279### Performance
280
281- Use @defer and @stream for large responses
282- Implement DataLoader to solve N+1 queries
283- Consider persisted queries for production
284- Use caching headers and CDN where appropriate
285
286## Ground Rules
287
288- ALWAYS use Apollo Server 5.x patterns (not v4 or earlier)
289- ALWAYS type your context with TypeScript generics
290- ALWAYS use GraphQLError from graphql package for errors
291- NEVER expose stack traces in production errors
292- PREFER startStandaloneServer for prototyping only
293- USE an integration with a server framework like Express, Koa, Fastify, Next, etc. for production apps
294- IMPLEMENT authentication in context, authorization in resolvers
295
In the file
SKILL.md935 words
Files7
LicenceMIT
Why you can read it

Nothing in a skill executes. The client loads the text and the model follows it, so a skill can be audited the way a runbook is — by reading it.

What it costs in context

Skills are not billed by the call. They are paid for in context: every token the instructions occupy is a token your code, your diff and your conversation cannot use. Here is what this one takes and when it takes it.

≈160
always loaded
The name and description, so the model knows the skill exists and when to reach for it.
16,340
on trigger
The instruction body and 6 supporting files, read only when the skill fires.
8.3%
of a 200k window
Ten skills this size would take about 83% of the window before you open a file.
050k100k150k200k context window

16.5k tokens, estimated from the bundle at four bytes to the token, held for the rest of the session once it triggers. Heavy. Teams tend to install this one per project rather than globally, and load it only when the job comes up.

Servers bill, skills cost

A server charges by the month. A skill charges once per session, in context, and then keeps charging it for as long as the session lives.

Before and after

The same question, put to the same model twice: once as it comes, and once with these instructions loaded.

No worked example has been published for this skill yet.

Adoption
Installsnone yet
Ratingno reviews yet

The procedure it runs

The procedure has not been published here. It is in the skill’s own SKILL.md, which its author has not sent to the marketplace yet.

Prose, not code

These steps are written for a model to follow, not executed by a runtime. It can still be told to skip one, and it will say so when it does.

Servers it uses

None. This skill calls no MCP servers at all.

Everything it needs is in the instructions, so it works in a project with nothing connected — the model reads the file and changes how it works with what it can already reach.

It asks the agent to write files, using whatever file access your client already has. It never touches the network.

What it asks for
Writes filesyes
Network accessno

Read from the allowed-tools line of this skill’s own SKILL.md. A skill grants no permissions of its own — it can only ask for tools your client already has.

What it will not do

Every skill is narrow, and the useful ones say where they stop. These are the jobs this one is the wrong tool for.

What this skill is not for has not been published here. Nothing is implied by that: it is a section the author has not filled in.

What is in the bundle

7 files, 66.0 kB on disk. A bundle is text throughout: the instructions the model reads, plus the templates it fills in.

  • SKILL.md7.2 kB
  • references/context-and-auth.md10.0 kB
  • references/data-sources.md9.2 kB
  • references/error-handling.md10.2 kB
  • references/plugins.md11.0 kB
  • references/resolvers.md8.1 kB
  • references/troubleshooting.md10.3 kB
What is not in it

No dependencies and nothing executable: a skill is text the agent reads, so the bundle is 7 files you can review in full before installing. The MIT licence covers the templates and examples as well as the instructions.

Install

Installing copies the bundle into your project. Nothing runs at install time — the files sit on disk until the model reads them.

# Apollo Server · 16.5k tokens when loaded npx mcprush@latest skill add apollographql/apollo-server

Writes to .claude/skills/apollo-server/ in the current project. Add --global to put it in your home directory instead, for every project.

Which clients pick it up on their own

A skill is a folder of text. A client with a skills folder reads it without being told; everywhere else the same text works, it is just handed to the model rather than found.

Claude Code.claude/skills/
Claude Desktop
ChatGPT
Cursor.cursor/skills/
VS Code.github/skills/
Codex CLI.agents/skills/
Gemini CLI.gemini/skills/
Grok.grok/skills/
Zed.agents/skills/
Windsurf.windsurf/skills/
Agent SDK.claude/skills/
HTTP / API
This release
Version1.0.0
Publishedno release date on file
PriceFree
Referenceapollographql/apollo-server

Versions

v1.0.0 is what is on the shelf; no release here carries a date. Instructions change more often than APIs do — a skill can be rewritten entirely without anything it depends on moving.

v1.0.0
  • No earlier releases have been published to the marketplace.
Pinning

Put apollographql/apollo-server@1.0.0 in the install command to hold this exact version. Without the suffix you get whatever is current the day you install, and nothing moves under you afterwards.

Reviews

no reviews yet · no installs yet

Nobody has reviewed this skill yet. The rating is the mean of the reviews written here, so there is none until somebody writes the first.

Who can post

Only accounts that have had the skill installed for fourteen days, so a review is written after living with it rather than after reading it. Publishers may reply once.

Publisher
Servers0