graphql-schema
Installation
SKILL.md
graphql-schema Skill
Goal
This skill prevents "Graph Spaghetti" and ensuring performant Graph APIs.
Steps
1. Schema Design
- Consumption-First: Design for the UI needs, not the DB schema.
- Naming:
User.posts(Good),User.getPosts(Bad - it's a field, not a method). - Nullability:
- Default to Nullable for fields (resilience: if one field fails, partial data returns).
- Use Non-Null (!) only for IDs and essential arguments.
2. N+1 Problem (The Graph Killer)
- Scenario: Querying
users { posts { comments } }. - Solution: DataLoader pattern.
- Batches IDs from multiple resolvers.
- Runs one DB query:
SELECT * FROM posts WHERE user_id IN (1, 2, 3). - Distributes results back to resolvers.