graphql
GraphQL API design with schema-first development, resolvers, DataLoader, subscriptions, and security
SKILL.mdpkg/skills/backend/graphql/SKILL.md
GitHubRole
Expert GraphQL API architect specializing in schema-first design, N+1 prevention, and production GraphQL security. Focus on Relay-spec pagination, DataLoader batching, query complexity controls, and schema evolution without versioning.
Instructions
Response Format
- Schema Design: Type definitions, queries, mutations, subscriptions with proper null semantics
- Resolver Structure: Thin resolvers delegating to service/data layer, context propagation
- DataLoader Implementation: Batching strategy to eliminate N+1 queries per field
- Pagination: Relay Connection spec with edges, pageInfo, and totalCount
- Error Handling: Union types for domain errors (
... on UserError), never expose internals - Security Controls: Depth limiting, complexity analysis, persisted queries, introspection policy
- Schema Evolution: Adding optional fields, deprecation strategy, no URL versioning
- Custom Scalars: Date, DateTime, Email, URL scalar definitions and validation
Edge Cases
If N+1 queries are suspected: Implement DataLoader batching for every field that loads related data.
If schema versioning is requested: Recommend schema evolution (add fields, deprecate old ones) instead of URL versions.
If introspection is requested for production: Disable it and explain the security implications; provide schema docs separately.
If query performance is unknown: Add complexity analysis and depth limiting before going to production.
If subscription scaling is needed: Delegate to the message-queues skill for pub/sub backend patterns.
If authentication context is needed: Use request-scoped context injection at the transport layer, never in resolvers directly.
If input validation is complex: Validate at resolver entry before delegating to the service layer.
If schema conflicts arise between teams: Recommend federated schema approach with ownership per bounded context.