Synthèse automatique
Guide la construction d'un serveur GraphQL prêt pour la production : schéma SDL ou code-first, resolvers optimisés par DataLoader, abonnements WebSocket et autorisation au niveau des champs.
Points forts
- Couvre un flux de travail ordonné, de la conception du schéma jusqu'aux scalaires personnalisés, directives, abonnements et génération de types
- Traite explicitement le problème N+1 via DataLoader ainsi que la limitation de profondeur et de complexité des requêtes
- Supporte plusieurs écosystèmes : Apollo Server, Yoga et Mercurius côté Node.js, Strawberry et Ariadne côté Python
- Fournit un tableau d'erreurs concret qui associe chaque symptôme à une solution
Limites
- Suppose des prérequis externes (Redis, ORM, graphql-codegen) que la skill n'installe ni ne configure
- Vise surtout les projets neufs : la migration d'une API existante n'est pas abordée
- Les chemins de sortie utilisent des variables de la skill et le guide détaillé réside dans un fichier de références séparé
À utiliser lorsque vous démarrez une nouvelle API GraphQL ou ajoutez schéma, resolvers et abonnements à un backend Node.js ou Python.
À éviter pour du REST ou du gRPC, ou si vous cherchez seulement à consommer une API GraphQL existante depuis un client.
Analyse de sécurité
PrudenceThe skill is a legitimate GraphQL development guide with no malicious intent or destructive instructions. It does grant Bash and file-edit capabilities for scaffolding/testing, so it is caution rather than safe, but the scope appears constrained and purpose-appropriate.
- •Allowed tools include Bash(api:graphql-*), which permits command execution within that scope; no destructive commands are specified in SKILL.md.
- •Write/Edit permissions can create or modify files under the skill/project directories, as intended for scaffolding GraphQL servers.
- •References external URLs and may use network/package tooling indirectly, but no credential exfiltration or obfuscated payloads are present.
Exemples
Build a GraphQL API for our e-commerce catalog with products, categories and reviews, using Apollo Server and Prisma. Include DataLoader batching and a paginated products query.Add real-time subscriptions to our Yoga GraphQL server so clients are notified when an order status changes, using graphql-ws and Redis pub/sub.Our GraphQL endpoint is being hit by deeply nested queries — add depth limiting, query complexity analysis and field-level @auth directives.name: building-graphql-server description: | 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".
allowed-tools: Read, Write, Edit, Grep, Glob, Bash(api:graphql-*) version: 1.0.0 author: Jeremy Longshore jeremy@intentsolutions.io license: MIT compatible-with: claude-code, codex, openclaw tags: [api, graphql, graphql-server]
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-codegenfor TypeScript type generation from schema (recommended)
Instructions
- Examine existing data models, database schemas, and business requirements using Read and Glob to determine the entity graph and relationship structure.
- Design the GraphQL schema with type definitions, including
Query,Mutation, andSubscriptionroot types, input types for mutations, and connection types for paginated lists. - Implement resolvers for each field, using DataLoader to batch and deduplicate database queries for nested relationships (N+1 query prevention).
- Add input validation on mutation arguments using custom scalars (DateTime, Email, URL) and directive-based validation (
@constraint(minLength: 1, maxLength: 255)). - Implement field-level authorization using schema directives (
@auth(requires: ADMIN)) or resolver middleware that checks user roles from the GraphQL context. - Configure query complexity analysis and depth limiting to prevent abusive queries (maximum depth of 7, maximum complexity score of 1000).
- Set up real-time subscriptions using
graphql-wsprotocol over WebSocket with Redis pub/sub for multi-instance message distribution. - Generate TypeScript types from the schema using
graphql-codegento ensure type safety between schema definitions and resolver implementations. - Write integration tests using
executeOperationfor 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-wsprotocol: https://github.com/enisdenjo/graphql-ws
Du fichier au premier essai
Le téléchargement contient exactement le contenu affiché sur cette fiche. Cette copie peut différer de la dernière version du dépôt source.
Consulter la source et ses fichiers annexesCe téléchargement contient uniquement SKILL.md. Les scripts, références, modèles et dépendances éventuels ne sont pas inclus. Récupérez les fichiers nécessaires depuis la source en conservant leur arborescence avant de poursuivre.
1. Télécharger le fichier
Télécharger SKILL.mdDepuis la racine d’un projet de test, enregistrez le fichier sous .skill-downloads/building-graphql-server-mryiqhu9/SKILL.md, ou utilisez la commande suivante. Ce dossier sert à examiner la skill avant son installation.
Commande pour macOS/Linux ou WSL : un shell POSIX et curl sont nécessaires. Sous Windows sans WSL, utilisez le bouton de téléchargement et créez le dossier manuellement.
mkdir -p '.skill-downloads/building-graphql-server-mryiqhu9' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/building-graphql-server-mryiqhu9/download' --output '.skill-downloads/building-graphql-server-mryiqhu9/SKILL.md.part' && mv '.skill-downloads/building-graphql-server-mryiqhu9/SKILL.md.part' '.skill-downloads/building-graphql-server-mryiqhu9/SKILL.md'2. Vérifier les prérequis
Lisez SKILL.md avant de l’utiliser. Si le fichier cite des scripts ou services externes, examinez-les et préparez les accès nécessaires dans votre environnement de test.
Outils déclarés par l’auteur (à vérifier dans votre agent) : Read, Write, Edit, Grep, Glob, Bash(api:graphql-*)
Extrait original : 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-codegenfor TypeScript type generation from schema (recommended)
Les plateformes de la fiche sont des indications du catalogue. Les chemins ci-dessous suivent la documentation des outils ; ils ne prouvent pas que cette skill y a été exécutée. Aucune version minimale de ces outils n’est attestée pour cette fiche.
3. Charger la skill
Après vérification, copiez le dossier complet dans le projet avec l’une des commandes ci-dessous, puis ouvrez une nouvelle session de l’outil. La commande s’arrête si un dossier du même nom existe déjà : comparez les fichiers avant de le remplacer.
Claude Code
test -f '.skill-downloads/building-graphql-server-mryiqhu9/SKILL.md' && test -s '.skill-downloads/building-graphql-server-mryiqhu9/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/building-graphql-server' && cp -R '.skill-downloads/building-graphql-server-mryiqhu9' '.claude/skills/building-graphql-server'Codex
test -f '.skill-downloads/building-graphql-server-mryiqhu9/SKILL.md' && test -s '.skill-downloads/building-graphql-server-mryiqhu9/SKILL.md' && mkdir -p '.agents/skills' && test ! -e '.agents/skills/building-graphql-server' && cp -R '.skill-downloads/building-graphql-server-mryiqhu9' '.agents/skills/building-graphql-server'OpenSkills
OpenSkills doit déjà être installé. La procédure locale install/read est contrôlée avec OpenSkills 1.5.0, qui exige Node.js ≥ 20.6.0. Aucun slug du catalogue n’est résolu automatiquement.
Installation officielle d’OpenSkillsopenskills install './.skill-downloads/building-graphql-server-mryiqhu9'openskills read 'building-graphql-server-mryiqhu9'La lecture doit afficher le contenu du fichier installé et son dossier de base. Elle ne lance ni la skill ni ses dépendances.
Pour un agent qui lit AGENTS.md, synchronisez ensuite l’index. Cette commande modifie AGENTS.md : relisez le diff avant de l’utiliser.
openskills syncMode manuel ou autre outil : joignez SKILL.md à une conversation, ou ouvrez-le dans un agent capable de lire les fichiers. Ajoutez les ressources annexes nécessaires. Il n’existe pas de dossier universel reconnu par tous les outils.
4. Faire un premier essai
Utilisez une entrée courte et fictive : un endpoint d’API, un petit document ou un brief d’interface. Dans une nouvelle conversation, joignez le fichier ou donnez son chemin à l’agent, puis adaptez cette demande :
Lis .skill-downloads/building-graphql-server-mryiqhu9/SKILL.md et applique ses instructions à cet exemple : [décrire une entrée de test]. Indique les fichiers, dépendances ou accès qui manquent. Produis le résultat demandé par la skill sans inventer de données ni exécuter de script non examiné.Résultat attendu : une sortie correspondant aux instructions de la skill, ou une liste précise des prérequis manquants. Une simple confirmation de lecture ne valide pas le premier usage. Si une ressource externe est indisponible, ce parcours reste à tester.
Bonnes pratiques React Hook Form
Developpement
Maîtrisez React Hook Form : évitez les anti-patterns, gérez les abonnements, et traitez correctement reset, dirty state et entrées contrôlées.
Migration Emotion vers Mantine
Developpement
Migrer les styled-components Emotion vers des composants Mantine avec style props et modules CSS. Pour convertir .styled.tsx ou supprimer les imports @emotion.
Détecteur de dérive de périmètre
Developpement
Analyse les diffs git par rapport à une intention pour détecter la dérive de périmètre, fichiers non liés et PR trop larges, puis suggère de garder, diviser ou justifier.