Use when building GraphQL APIs with Apollo Server requiring resolvers, data sources, schema design, and federation.
View on GitHubTheBushidoCollective/han
jutsu-apollo-graphql
January 24, 2026
Select agents to install to:
npx add-skill https://github.com/TheBushidoCollective/han/blob/main/jutsu/jutsu-apollo-graphql/skills/apollo-server-patterns/SKILL.md -a claude-code --skill apollo-server-patternsInstallation paths:
.claude/skills/apollo-server-patterns/# Apollo Server Patterns
Master Apollo Server for building production-ready GraphQL APIs with proper
schema design, efficient resolvers, and scalable architecture.
## Overview
Apollo Server is a spec-compliant GraphQL server that works with any GraphQL
schema. It provides features like schema stitching, federation, data sources,
and built-in monitoring for production GraphQL APIs.
## Installation and Setup
### Installing Apollo Server
```bash
# For Express
npm install @apollo/server graphql express cors body-parser
# For standalone server
npm install @apollo/server graphql
# Additional utilities
npm install graphql-tag dataloader
```
### Basic Server Setup
```javascript
// server.js
import { ApolloServer } from '@apollo/server';
import { startStandaloneServer } from '@apollo/server/standalone';
import { typeDefs } from './schema.js';
import { resolvers } from './resolvers.js';
const server = new ApolloServer({
typeDefs,
resolvers,
formatError: (formattedError, error) => {
// Custom error formatting
if (formattedError.extensions?.code === 'INTERNAL_SERVER_ERROR') {
return {
...formattedError,
message: 'An internal error occurred'
};
}
return formattedError;
},
plugins: [
{
async requestDidStart() {
return {
async willSendResponse({ response }) {
console.log('Response sent');
}
};
}
}
]
});
const { url } = await startStandaloneServer(server, {
listen: { port: 4000 },
context: async ({ req }) => {
const token = req.headers.authorization || '';
const user = await getUserFromToken(token);
return { user };
}
});
console.log(`Server ready at ${url}`);
```
## Core Patterns
### 1. Schema Definition
```javascript
// schema.js
import { gql } from 'graphql-tag';
export const typeDefs = gql`
type User {
id: ID!
email: String!
name: String!
posts: [Post!]!
createdAt: String!
}
type Post {
id: