Skip to content
building-graphql-server logo

Building GraphQL Server

building-graphql-server

Build production-ready GraphQL servers with schema design, resolvers,

SKILL.md

Full skill instructions

Building GraphQL Server

Overview

Build production-ready GraphQL servers with SDL-first or code-first schema design, efficient resolver implementations with DataLoader batching, real-time subscriptions via WebSocket, and field-level authorization. Support Apollo Server, Yoga, Mercurius, and Strawberry across Node.js and Python runtimes.

Prerequisites

  • Node.js 18+ with Apollo Server/​Yoga/​Mercurius, or Python 3.10+ with Strawberry/​Ariadne
  • Database with ORM (Prisma, TypeORM, SQLAlchemy) for resolver data sources
  • Redis for subscription pub/​sub and DataLoader caching (production deployments)
  • GraphQL client for testing: GraphiQL, Apollo Studio, or Insomnia
  • graphql-codegen for TypeScript type generation from schema (recommended)

Instructions

  1. Examine existing data models, database schemas, and business requirements using Read and Glob to determine the entity graph and relationship structure.
  2. Design the GraphQL schema with type definitions, including Query, Mutation, and Subscription root types, input types for mutations, and connection types for paginated lists.
  3. Implement resolvers for each field, using DataLoader to batch and deduplicate database queries for nested relationships (N+1 query prevention).
  4. Add input validation on mutation arguments using custom scalars (DateTime, Email, URL) and directive-based validation (@constraint(minLength: 1, maxLength: 255)).
  5. Implement field-level authorization using schema directives (@auth(requires: ADMIN)) or resolver middleware that checks user roles from the GraphQL context.
  6. Configure query complexity analysis and depth limiting to prevent abusive queries (maximum depth of 7, maximum complexity score of 1000).
  7. Set up real-time subscriptions using graphql-ws protocol over WebSocket with Redis pub/​sub for multi-instance message distribution.
  8. Generate TypeScript types from the schema using graphql-codegen to ensure type safety between schema definitions and resolver implementations.
  9. Write integration tests using executeOperation for query/​mutation testing and WebSocket client tests for subscription verification.

See ${CLAUDE_SKILL_DIR}/​references/​implementation.md for the full implementation guide.

Output

  • ${CLAUDE_SKILL_DIR}/​src/​schema/ - GraphQL SDL type definitions organized by domain
  • ${CLAUDE_SKILL_DIR}/​src/​resolvers/ - Resolver implementations per type with DataLoader integration
  • ${CLAUDE_SKILL_DIR}/​src/​dataloaders/ - DataLoader factories for batched database queries
  • ${CLAUDE_SKILL_DIR}/​src/​directives/ - Custom schema directives (auth, validation, caching)
  • ${CLAUDE_SKILL_DIR}/​src/​scalars/ - Custom scalar type definitions (DateTime, JSON, Email)
  • ${CLAUDE_SKILL_DIR}/​src/​subscriptions/ - Subscription resolvers with pub/​sub configuration
  • ${CLAUDE_SKILL_DIR}/​generated/​types.ts - Auto-generated TypeScript types from schema

Error Handling

ErrorCauseSolution
N+1 query detectedResolver fetches related records individually inside list resolverWrap data access in DataLoader; batch by parent ID array; cache within request scope
Query complexity exceededClient sends deeply nested query exceeding complexity budgetReturn error with current complexity score and maximum allowed; suggest query simplification
Subscription connection droppedWebSocket heartbeat timeout or network interruptionImplement automatic reconnection in client; use graphql-ws connectionInitWaitTimeout
Partial resolver failureOne field resolver throws while others succeedReturn partial data with errors array per GraphQL spec; log failed resolver with context
Schema stitching conflictDuplicate type names when merging multiple schema modulesUse schema namespacing or federation with @key directives to resolve type ownership

Refer to ${CLAUDE_SKILL_DIR}/​references/​errors.md for comprehensive error patterns.

Examples

E-commerce product catalog: Schema with Product, Category, Review types, DataLoader-backed resolvers for nested queries like products { reviews { author } }, and a productUpdated subscription for inventory changes.

Multi-tenant SaaS dashboard: Code-first schema using TypeGraphQL decorators, tenant-scoped resolvers extracting tenantId from JWT context, and field-level visibility based on subscription plan tier.

Federated microservice graph: Apollo Federation with @key and @external directives across User, Order, and Product subgraphs, composed into a unified supergraph with a gateway router.

See ${CLAUDE_SKILL_DIR}/​references/​examples.md for additional examples.

Resources

More skills from jeremylongshore

openrouter-compliance-review logo
jeremylongshore/claude-code-plugins-plus-skills

openrouter-compliance-review

Review OpenRouter integration for regulatory compliance (SOC2, GDPR,

2.8K 0
View
maintainx-data-handling logo
jeremylongshore/claude-code-plugins-plus-skills

maintainx-data-handling

Data synchronization, ETL patterns, and data management for MaintainX.

2.8K 0
View
groq-core-workflow-a logo
jeremylongshore/claude-code-plugins-plus-skills

groq-core-workflow-a

Execute Groq primary workflow: chat completions with tool use and JSON

2.8K 0
View
validating-csrf-protection logo
jeremylongshore/claude-code-plugins-plus-skills

validating-csrf-protection

Validate CSRF protection implementations for security gaps. Use when

2.8K 0
View
api-contract logo
jeremylongshore/claude-code-plugins-plus-skills

api-contract

Configure this skill should be used when the user asks about "API contract",

2.8K 0
View
ideogram-incident-runbook logo
jeremylongshore/claude-code-plugins-plus-skills

ideogram-incident-runbook

Execute Ideogram incident response with triage, mitigation, and postmortem.

2.8K 0
View
gamma-sdk-patterns logo
jeremylongshore/claude-code-plugins-plus-skills

gamma-sdk-patterns

Reusable patterns for the Gamma REST API (no SDK exists).

2.8K 0
View
deepgram-sdk-patterns logo
jeremylongshore/claude-code-plugins-plus-skills

deepgram-sdk-patterns

Apply production-ready Deepgram SDK patterns for TypeScript and Python.

2.8K 0
View
openrouter-upgrade-migration logo
jeremylongshore/claude-code-plugins-plus-skills

openrouter-upgrade-migration

Migrate to OpenRouter from direct provider APIs or upgrade between SDK/model

2.8K 0
View
openrouter-common-errors logo
jeremylongshore/claude-code-plugins-plus-skills

openrouter-common-errors

Diagnose and fix common OpenRouter API errors. Use when encountering

2.8K 0
View
linear-cost-tuning logo
jeremylongshore/claude-code-plugins-plus-skills

linear-cost-tuning

Optimize Linear API usage, reduce unnecessary calls, and maximize

2.8K 0
View

Popular AI tools

Kaiber logo
Video

Kaiber

Generate, edit, and beat-sync AI video with leading models in one workspace.

Paid
View
Vimcal logo
Productivity

Vimcal

The world's fastest calendar for remote work

Free
View

Transform Your Design with AI Designer by ImgCreator.ai

Freemium
View
Akool AI logo
Content & writing

Akool AI

Revolutionizing Video Production with AI-Powered Creativity

Paid
View

Extend an image past the frame and let AI fill the new aspect ratio.

Freemium
View
StarByFace logo
Security

StarByFace

Discover your celebrity doppelgänger with StarByFace!

Free
View
C

ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.

Freemium
View
Opus Clip logo
Coding & apps

Opus Clip

Opus.ai: Revolutionize Your Web Experience

Free
View