GraphQL Design Guide
Paste the following prompt into your AI chat to install this skill:
Install @user_3c6cb52e/graphql-design-sh-4mq9ya by following https://skillhub.cn/install/skillhub.md.
About this skill
Problem
GraphQL APIs modeled too closely after database tables often run into the same issues: nested fields trigger N+1 queries, large lists suffer when using offset pagination, mutations return data without a consistent error shape, and schema files grow into a monolith. This skill turns those problems into concrete design constraints, making it useful before adding endpoints, refactoring resolvers, or reviewing a schema.
How It Works
It centers on schema design, resolvers, and subscriptions. List fields should use Relay-style connections for cursor pagination. Batched entity lookups should use DataLoader, with fresh instances created per request to avoid stale or cross-user cache state. Mutations should return payload types containing both result and errors, while mutation arguments use Input types. The guidance also emphasizes splitting the schema into domain-specific modules and configuring query depth and complexity limits to reduce the risk of unbounded queries.
Boundaries
This material is best used as a design or review checklist for API design, code review, and team standards, especially when a team needs consistent GraphQL rules. It does not replace runtime concerns such as authorization, caching, gateway rate limiting, or subscription infrastructure. For complex multi-tenant or federated schemas, validate the recommendations against your framework and operational constraints.
Use Cases
- When adding a GraphQL list endpoint, define connections and cursor pagination using the Relay pattern.
- During resolver review, check whether batched entity lookups use DataLoader to prevent N+1 queries.
- When refactoring mutation responses, standardize payload types that include both result and errors.
- Before release, verify subscription topics are filtered to avoid broadcasting to all clients.
Best For
- Backend engineers designing APIs who need consistent GraphQL schema and pagination rules.
- Tech leads conducting code reviews who need to check DataLoader usage and error payloads.
- Developers maintaining GraphQL services who need to reduce N+1 queries and unbounded complexity.
- Backend engineers building subscription endpoints who need topic filtering and modular schemas.
Related Skills
Guides Java Spring Boot backend development across REST APIs, data access, security, microservices, testing, deployment, and troubleshooting.
A systematic code error fixing skill that follows a five-step workflow: Reproduce, Isolate, Understand, Fix, Verify, to help developers resolve code errors.
Restores Lanhu designs to target framework code using schema JSON, design tokens, and image assets.
Automatically detects engineering or competition code, analyzes bugs, vulnerabilities, algorithm complexity, and edge cases, then produces risk-level findings with before/after fixes.