# GRAPHQL

> GraphQL API design, schema patterns, resolvers, and client usage. Use when this capability is needed.

- Skill: `tomevault-io/graphql-8` (Agent Skill, multi-file: 2 files)
- Install (CLI): `npx skillmds@latest add tomevault-io/graphql-8`
- Raw SKILL.md: https://api.skillmd.com/api/skills/tomevault-io/graphql-8/raw
- Safety review: pending (external: skill-scanner PASS, skillspector PASS)
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Integrations & APIs
- Author: tomevault-io (https://skillmd.com/u/tomevault-io)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/tomevault-io/graphql-8

---


# GraphQL Best Practices

## Schema Design
- Use descriptive type names (User, not UserType)
- Use connections pattern for pagination (Relay-style)
- Use input types for mutations
- Use enums for fixed values
- Use interfaces/unions for polymorphism
- Keep schema as the source of truth

## Resolvers
- Keep resolvers thin — delegate to services
- Use DataLoader for N+1 prevention
- Return errors in the response, don't throw
- Use context for auth, dataloaders, services

## Performance
- Use persisted queries in production
- Implement query complexity analysis
- Set depth limits on queries
- Use `@defer` and `@stream` for large responses
- Cache at resolver level with DataLoader

## Security
- Disable introspection in production
- Validate input depth and complexity
- Use field-level authorization
- Rate limit by query complexity

---
> Source: [kprsnt2/MyLocalCLI](https://github.com/kprsnt2/MyLocalCLI) — distributed by [TomeVault](https://tomevault.io).
<!-- tomevault:4.0:skill_md:2026-06-15 -->

