BU

building-graphql-server

Provides a framework for building GraphQL APIs with schema design, DataLoader batching, and real-time subscription support.

Install

mkdir -p .claude/skills/building-graphql-server && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/3528" && unzip -o skill.zip -d .claude/skills/building-graphql-server && rm skill.zip

Installs to .claude/skills/building-graphql-server

Activation

This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.

Build production-ready GraphQL servers with schema design, resolvers,
69 charsno explicit “when” trigger
Advanced

Key capabilities

  • Design GraphQL schemas with type definitions, queries, mutations, and subscriptions.
  • Implement resolvers with DataLoader for efficient database batching.
  • Add input validation using custom scalars and directive-based constraints.
  • Implement field-level authorization with schema directives or resolver middleware.
  • Configure query complexity analysis and depth limiting to prevent abusive queries.

How it works

This skill guides the construction of GraphQL servers by designing schemas, implementing resolvers with data batching, adding validation and authorization, and setting up real-time subscriptions using WebSocket with Redis pub/sub.

Inputs & outputs

You give it
Data models, database schemas, and business requirements.
You get back
GraphQL SDL type definitions, resolver implementations, and subscription configurations.

When to use building-graphql-server

  • Design GraphQL schema definitions
  • Implement resolvers with database batching
  • Setup real-time GraphQL subscriptions
  • Generate TypeScript types from GraphQL schemas

About this skill

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

When not to use it

  • When a REST API is sufficient for data access.
  • When real-time subscriptions or complex data fetching patterns are not required.

Prerequisites

Node.js 18+ with Apollo Server/Yoga/Mercurius, or Python 3.10+ with Strawberry/AriadneDatabase with ORM (Prisma, TypeORM, SQLAlchemy)Redis for subscription pub/sub and DataLoader caching (production deployments)GraphQL client for testing: GraphiQL, Apollo Studio, or Insomnia

Limitations

  • N+1 query issues require DataLoader implementation.
  • Query complexity limits may be exceeded by deeply nested queries.
  • Subscription connection drops require client-side automatic reconnection.

How it compares

This skill provides a structured approach to building production-ready GraphQL servers, including advanced features like DataLoader for N+1 query prevention and field-level authorization, which are not typically part of a basic API setup.

Compared to similar skills

building-graphql-server side by side with the closest alternatives in the catalog.

SkillInstallsUpdatedSafetyDifficulty
building-graphql-server (this skill)127dReviewAdvanced
mcp-builder1363moReviewAdvanced
architecture-patterns552moNo flagsAdvanced
telegram-bot-builder1066moReviewIntermediate

Try saying

Example prompts that trigger this skill in your AI assistant.

More by jeremylongshore

View all by jeremylongshore

analyzing-logs

jeremylongshore

Analyze application logs to detect performance issues, identify error patterns, and improve stability by extracting key insights.

14123

ollama-setup

jeremylongshore

Configure auto-configure Ollama when user needs local LLM deployment, free AI alternatives, or wants to eliminate hosted API costs. Trigger phrases: "install ollama", "local AI", "free LLM", "self-hosted AI", "replace OpenAI", "no API costs". Use when appropriate context detected. Trigger with relevant phrases based on skill purpose.

1167

backtesting-trading-strategies

jeremylongshore

Backtest crypto and traditional trading strategies against historical data. Calculates performance metrics (Sharpe, Sortino, max drawdown), generates equity curves, and optimizes strategy parameters. Use when user wants to test a trading strategy, validate signals, or compare approaches. Trigger with phrases like "backtest strategy", "test trading strategy", "historical performance", "simulate trades", "optimize parameters", or "validate signals".

1071

generating-database-seed-data

jeremylongshore

Process this skill enables AI assistant to generate realistic test data and database seed scripts for development and testing environments. it uses faker libraries to create realistic data, maintains relational integrity, and allows configurable data volumes. u... Use when working with databases or data models. Trigger with phrases like 'database', 'query', or 'schema'.

1033

cursor-codebase-indexing

jeremylongshore

Execute set up and optimize Cursor codebase indexing. Triggers on "cursor index setup", "codebase indexing", "index codebase", "cursor semantic search". Use when working with cursor codebase indexing functionality. Trigger with phrases like "cursor codebase indexing", "cursor indexing", "cursor".

885

testing-mobile-apps

jeremylongshore

Execute mobile app testing on iOS and Android devices/simulators. Use when performing specialized testing. Trigger with phrases like "test mobile app", "run iOS tests", or "validate Android functionality".

810

You might also like

mcp-builder

anthropics

Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK).

136215

architecture-patterns

wshobson

Implement proven backend architecture patterns including Clean Architecture, Hexagonal Architecture, and Domain-Driven Design. Use when architecting complex backend systems or refactoring existing applications for better maintainability.

55214

telegram-bot-builder

davila7

Expert in building Telegram bots that solve real problems - from simple automation to complex AI-powered bots. Covers bot architecture, the Telegram Bot API, user experience, monetization strategies, and scaling bots to thousands of users. Use when: telegram bot, bot api, telegram automation, chat bot telegram, tg bot.

106130

stripe-integration

wshobson

Implement Stripe payment processing for robust, PCI-compliant payment flows including checkout, subscriptions, and webhooks. Use when integrating Stripe payments, building subscription systems, or implementing secure checkout flows.

48165

azure-functions

aj-geddes

Create serverless functions on Azure with triggers, bindings, authentication, and monitoring. Use for event-driven computing without managing infrastructure.

10104

langchain-architecture

wshobson

Design LLM applications using the LangChain framework with agents, memory, and tool integration patterns. Use when building LangChain applications, implementing AI agents, or creating complex LLM workflows.

899

Search skills

Search the agent skills registry