building-graphql-server

Build production-ready GraphQL servers with schema design, resolvers, and subscriptions. Use when building GraphQL APIs with schemas and resolvers. Trigger with phrases like "build GraphQL API", "create GraphQL server", or "setup GraphQL".

1,868 stars

Best use case

building-graphql-server is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

Build production-ready GraphQL servers with schema design, resolvers, and subscriptions. Use when building GraphQL APIs with schemas and resolvers. Trigger with phrases like "build GraphQL API", "create GraphQL server", or "setup GraphQL".

Teams using building-graphql-server should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/building-graphql-server/SKILL.md --create-dirs "https://raw.githubusercontent.com/jeremylongshore/claude-code-plugins-plus-skills/main/plugins/api-development/graphql-server-builder/skills/building-graphql-server/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/building-graphql-server/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How building-graphql-server Compares

Feature / Agentbuilding-graphql-serverStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

Build production-ready GraphQL servers with schema design, resolvers, and subscriptions. Use when building GraphQL APIs with schemas and resolvers. Trigger with phrases like "build GraphQL API", "create GraphQL server", or "setup GraphQL".

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

Related Guides

SKILL.md Source

# 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

| Error | Cause | Solution |
|-------|-------|----------|
| N+1 query detected | Resolver fetches related records individually inside list resolver | Wrap data access in DataLoader; batch by parent ID array; cache within request scope |
| Query complexity exceeded | Client sends deeply nested query exceeding complexity budget | Return error with current complexity score and maximum allowed; suggest query simplification |
| Subscription connection dropped | WebSocket heartbeat timeout or network interruption | Implement automatic reconnection in client; use `graphql-ws` `connectionInitWaitTimeout` |
| Partial resolver failure | One field resolver throws while others succeed | Return partial data with `errors` array per GraphQL spec; log failed resolver with context |
| Schema stitching conflict | Duplicate type names when merging multiple schema modules | Use 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

- GraphQL Specification: https://spec.graphql.org/
- Apollo Server documentation: https://www.apollographql.com/docs/apollo-server/
- DataLoader pattern: https://github.com/graphql/dataloader
- `graphql-ws` protocol: https://github.com/enisdenjo/graphql-ws

Related Skills

building-terraform-modules

1868
from jeremylongshore/claude-code-plugins-plus-skills

Execute this skill empowers AI assistant to build reusable terraform modules based on user specifications. it leverages the terraform-module-builder plugin to generate production-ready, well-documented terraform module code, incorporating best practices for sec... Use when appropriate context detected. Trigger with relevant phrases based on skill purpose.

building-gitops-workflows

1868
from jeremylongshore/claude-code-plugins-plus-skills

Execute use when constructing GitOps workflows using ArgoCD or Flux. Trigger with phrases like "create GitOps workflow", "setup ArgoCD", "configure Flux", or "automate Kubernetes deployments". Generates production-ready configurations, implements best practices, and ensures security-first approach for continuous deployment.

building-cicd-pipelines

1868
from jeremylongshore/claude-code-plugins-plus-skills

Execute use when you need to work with deployment and CI/CD. This skill provides deployment automation and pipeline orchestration with comprehensive guidance and automation. Trigger with phrases like "deploy application", "create pipeline", or "automate deployment".

building-websocket-server

1868
from jeremylongshore/claude-code-plugins-plus-skills

Build scalable WebSocket servers for real-time bidirectional communication. Use when enabling real-time bidirectional communication. Trigger with phrases like "build WebSocket server", "add real-time API", or "implement WebSocket".

building-api-gateway

1868
from jeremylongshore/claude-code-plugins-plus-skills

Create API gateways with routing, load balancing, rate limiting, and authentication. Use when routing and managing multiple API services. Trigger with phrases like "build API gateway", "create API router", or "setup API gateway".

building-api-authentication

1868
from jeremylongshore/claude-code-plugins-plus-skills

Build secure API authentication systems with OAuth2, JWT, API keys, and session management. Use when implementing secure authentication flows. Trigger with phrases like "build authentication", "add API auth", or "secure the API".

building-recommendation-systems

1868
from jeremylongshore/claude-code-plugins-plus-skills

Execute this skill empowers AI assistant to construct recommendation systems using collaborative filtering, content-based filtering, or hybrid approaches. it analyzes user preferences, item features, and interaction data to generate personalized recommendations... Use when appropriate context detected. Trigger with relevant phrases based on skill purpose.

building-neural-networks

1868
from jeremylongshore/claude-code-plugins-plus-skills

Execute this skill allows AI assistant to construct and configure neural network architectures using the neural-network-builder plugin. it should be used when the user requests the creation of a new neural network, modification of an existing one, or assistance... Use when appropriate context detected. Trigger with relevant phrases based on skill purpose.

building-classification-models

1868
from jeremylongshore/claude-code-plugins-plus-skills

Build and evaluate classification models for supervised learning tasks with labeled data. Use when requesting "build a classifier", "create classification model", or "train classifier". Trigger with relevant phrases based on skill purpose.

building-automl-pipelines

1868
from jeremylongshore/claude-code-plugins-plus-skills

Build automated machine learning pipelines with feature engineering, model selection, and hyperparameter tuning. Use when automating ML workflows from data preparation through model deployment. Trigger with phrases like "build automl pipeline", "automate ml workflow", or "create automated training pipeline".

server-sent-events-setup

1868
from jeremylongshore/claude-code-plugins-plus-skills

Server Sent Events Setup - Auto-activating skill for API Integration. Triggers on: server sent events setup, server sent events setup Part of the API Integration skill category.

graphql-subscription-setup

1868
from jeremylongshore/claude-code-plugins-plus-skills

Graphql Subscription Setup - Auto-activating skill for API Development. Triggers on: graphql subscription setup, graphql subscription setup Part of the API Development skill category.