apollo-server
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.
Security Assessment
Detected risks:
About apollo-server
A practical guide to building GraphQL servers with Apollo Server 5.x, the framework-agnostic, open-source server that runs standalone or integrates with Express, Fastify, and serverless runtimes. It suits developers starting a new Apollo project, writing resolvers and schemas, wiring up authentication, building plugins or data sources, or troubleshooting server errors and performance problems. Guidance is pinned to the 5.x line and assumes Node.js v20+ and TypeScript 4.7+.
A quick-start sequence covers installing @apollo/server and graphql (adding @as-integrations/express5 for Express), declaring type definitions, writing resolvers, and starting the server. Two startup paths are shown: startStandaloneServer, positioned strictly for prototyping, and an Express integration with the drain-HTTP-server plugin for graceful shutdown that is recommended for production. Schema material walks through the built-in scalar types, object and input types, non-null markers, enums, and interfaces, while the resolver section explains the parent, args, contextValue, info signature and shows thin resolvers that delegate to data sources. A dedicated context section demonstrates building a per-request, TypeScript-typed context carrying tokens, the authenticated user, and data sources for both standalone and Express setups.
The skill closes with condensed rules and reference pointers: design schemas with meaningful non-null fields and input types, keep resolvers thin, batch with DataLoader to defeat N+1 queries, and consider @defer/@stream and persisted queries for performance. Its ground rules are firm - always use 5.x patterns, type the context with generics, raise errors as GraphQLError from the graphql package, never leak stack traces in production, and move to a real framework integration rather than the standalone server for production apps. Companion reference files expand on resolvers, context and auth, plugins, data sources, error handling, and troubleshooting.
FAQ
Which version of Apollo Server does this target?
It is written specifically for Apollo Server 5.x and instructs you to always use 5.x patterns rather than v4 or earlier.
What are the runtime requirements?
It states compatibility with Node.js v20+ and TypeScript 4.7+, and works with Express v4/v5, the standalone server, Fastify, and serverless environments.
Should I use startStandaloneServer in production?
No. The standalone server is recommended only for prototyping; for production you should integrate with a framework such as Express, Koa, Fastify, or Next.
How does it address N+1 query problems?
It recommends implementing DataLoader to batch related queries, and keeping resolvers thin by delegating to services or data sources.
How should errors be handled?
Always raise errors as GraphQLError from the graphql package, and never expose stack traces in production error responses.
Install apollo-server
Quick Setup:
- Copy the skill folder to
.claude/skills/ - Claude will automatically detect and use the skill
Repository
apollographql/skills