Agent skill
graphql
GraphQL API design and implementation patterns
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/other/other/graphql-baphled-dotopencode
SKILL.md
Skill: graphql
What I do
I provide GraphQL API expertise: schema design, type hierarchies, resolvers, query/mutation patterns, real-time subscriptions, error handling, pagination, and performance optimisation. I focus on building flexible, type-safe APIs that avoid overfetching and the N+1 query problem through the DataLoader pattern.
When to use me
- Designing GraphQL schemas (SDL) and type relationships
- Implementing resolvers for queries, mutations, and subscriptions
- Optimising data loading using DataLoaders to batch and cache queries
- Implementing cursor-based pagination (Relay spec) for large datasets
- Designing typed error payloads and schema-level validation
- Aggregating data from multiple microservices or database sources
- Implementing field-level authorisation and query complexity limiting
Core principles
- Schema-First Design - Define the contract between frontend and backend using a strongly-typed schema before implementation.
- Types Model the Domain - Model types based on domain concepts and client needs, not internal database structures.
- Nullable by Default - Embrace nullability; only use
!when a field is guaranteed to be present even in error states. - Efficient Data Loading - Always use the DataLoader pattern to batch field resolution and prevent N+1 query performance issues.
- Contract Evolution - Evolve the schema through deprecation and additive changes; avoid breaking existing clients.
Patterns & examples
Schema Design (SDL)
type User {
id: ID!
name: String!
orders(first: Int = 10, after: String): OrderConnection!
}
type Query {
me: User
user(id: ID!): User
}
type Mutation {
createOrder(input: CreateOrderInput!): CreateOrderPayload!
}
Resolver with DataLoader (Go)
// OrderResolver batches user lookups across all orders in a list
func (r *orderResolver) User(ctx context.Context, obj *model.Order) (*model.User, error) {
return GetLoaders(ctx).UserLoader.Load(ctx, obj.UserID)
}
Cursor Pagination (Relay)
type OrderConnection {
edges: [OrderEdge!]!
pageInfo: PageInfo!
totalCount: Int!
}
Anti-patterns to avoid
- ❌ Exposing database schema directly as the GraphQL schema.
- ❌ Missing DataLoaders for list resolvers; causes N+1 query degradation.
- ❌ Generic error strings; use typed error payloads with
fieldandmessage. - ❌ Offset pagination for large/frequent datasets; use opaque cursors.
- ❌ Deeply nested queries without depth or complexity limiting (DoS risk).
KB Reference
~/vaults/baphled/3. Resources/Knowledge Base/AI Development System/Skills/Languages/GraphQL.md
Related skills
api-design- General API design principlesdb-operations- Database and repository patternssql- Query optimisation and indexingerror-handling- Typed error patternssecurity- Authentication and query depth limitingarchitecture- Layer separation with repository pattern
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?