GRAPHQL

Use when: design or review GraphQL schemas and resolvers with safe, efficient data access.

kimtth 23af7d9 1.0 KB Updated

File contents

Goal: a typed GraphQL schema that is expressive and not abusable.

Use for:

  • designing schemas, types, and mutations
  • reviewing resolver efficiency and security
  • fixing N+1 queries and over-fetching risks

Workflow:

  1. Design the schema from the client's data needs.
  2. Model nullability and types precisely.
  3. Batch and cache resolver data with a dataloader pattern.
  4. Limit query depth and complexity to prevent abuse.
  5. Handle errors as typed results where it aids clients.
  6. Verify with schema tests and performance checks.

Patterns:

  • dataloaders to batch and dedupe per request
  • pagination via connections/edges
  • input types for mutations
  • persisted queries for trusted clients

Rules:

  • prevent N+1 with batching, not eager joins everywhere
  • cap query depth and complexity on public APIs
  • never expose internal errors raw to clients
  • evolve the schema additively; deprecate before removing

kimtth/agent-skill-100-lines-or-less/tree/main/skills/graphql commit 23af7d9f6e

Frequently asked questions

npx skillmds@latest add kimtth/graphql