graphql-schema
Skill1 starsChanged 38 days agoMITView on GitHub
Designs GraphQL schemas and resolvers that scale - domain-modeled types, Relay pagination, DataLoader batching to kill N+1, mutation payloads with typed user errors, and depth/complexity limits that stop abusive queries. Use when someone asks "how should I structure this GraphQL type", "my resolvers are hammering the database", "cursor or offset pagination", "how do I version a GraphQL API", or is designing or reviewing a schema or federation split. Do NOT use for REST or RPC endpoint design - use api-design instead; do NOT use for the underlying table design - use database-schema instead; for hunting existing N+1s in a codebase, use n-plus-one-hunter.
7 other projects use a version of this.
Adopted by
Most recently taken up by
- ishandutta2007/Awesome-Claude-Skillstheir own version, first seen Nov 8, 2026
- clidey/whodbtheir own version, first seen Nov 1, 2026
- whmathews15/claude-code-showcasetheir own version, first seen Oct 20, 2026
- ipoprock/claude-code-showcasetheir own version, first seen Oct 13, 2026
- manastalukdar/ai-devstudiotheir own version, first seen Oct 13, 2026
- apollographql/skillstheir own version, first seen Feb 2, 2026
Other versions7 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 7
- ChrisWiles/claude-code-showcase★ 6.1ksame name
- clidey/whodb★ 5.1ksame name
- apollographql/skills★ 123same name
- ishandutta2007/Awesome-Claude-Skills★ 16same name
- ipoprock/claude-code-showcase★ 1same name
- manastalukdar/ai-devstudio★ 1same name
- whmathews15/claude-code-showcase★ 1same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository6 other files it gives its agents.
- api-designSkill
- database-schemaSkill
- nextjs-app-routerSkill
- stripe-integrationSkill
- supabase-expertSkill
- web-performanceSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
14 rules. 0 are common, 10 are distinctive, and 4 are very specific to this project.
0
Common
Most of the 7 edited versions we read keep these.
10
Distinctive
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 24
Use schema-first SDL as the contract.
- Very specific: line 25
Prefer non-null (!) by default.
- Distinctive: line 48
Verify with a query log: a page-of-50-orders query should issue on the order of 2-3 SQL queries, not 51.
- Distinctive: line 65
Never expose raw database errors.
- Distinctive: line 121
Do not mirror database tables into the schema - you freeze your storage layout into a public contract.
- Distinctive: line 122
Do not ship an unbounded list field.
- Distinctive: line 123
Do not resolve relationships row-by-row.
- Distinctive: line 124
Do not share DataLoader instances across requests - cross-user cache leakage.
- Very specific: line 125
Do not model expected business failures as thrown GraphQL errors.
- Distinctive: line 126
Do not remove or retype a shipped field.
- Distinctive: line 127
Do not rely on entry-point auth.
- Very specific: line 131
Every type is a domain noun.
- Distinctive: line 132
Every list is a connection with an enforced page cap.
- Very specific: line 134
Every mutation returns a payload with userErrors.
“Common” is measured: kept by at least 6 in 10 of the 7 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
GraphQL Schema
A GraphQL schema is a public contract that clients build against for years, and a resolver layer is an open invitation for N+1 queries and abusive nesting. This skill designs schemas clients love and servers survive: model the domain rather than the database, batch every relationship resolver, and put hard limits on what a single query may cost - because removing a shipped field or fixing a hot N+1 under load is 10x the effort of designing it right.
Operating procedure
Step 1: Gather inputs
- The domain nouns and the operations clients actually need (screens/use-cases, not tables).
- Largest list sizes and expected query shapes; who the clients are (first-party only vs public API - public means stricter limits).
- Data sources behind each type and which relationships cross a database or service boundary.
- Single graph or federated subgraphs.
Step 2: Model the graph
- Model around domain nouns, not database tables - the schema is for clients; the database is an implementation detail (table design belongs to database-schema).
- Use schema-first SDL as the contract; generate types from it.
- Prefer non-null (
!) by default; make a field nullable only when null is a real, meaningful value or when the field's resolver can fail independently and you want partial results instead of a nulled-out parent chain. - Return rich object types, not scalars, so fields can grow without breaking clients.
- Mutations return a payload type carrying the mutated entity and a
userErrorslist - do not model expected business failures as top-level GraphQL errors.
Step 3: Paginate every list that can grow
- Cursor-based connections (Relay spec) for anything unbounded; offset pagination breaks under concurrent writes and invites
offset: 500000table scans. - Expose
edges { node cursor }andpageInfo { hasNextPage endCursor }. - Require
first/lastwith a hard cap - 100 is the standard ceiling; default to 20-25 when the client omits it. An uncapped list argument is a self-serve denial-of-service endpoint.
Step 4: Batch every relationship resolver
The classic trap: resolving items.customer fires one query per row. Every resolver that crosses a table or service boundary gets a DataLoader, created per-request (a shared loader leaks data across users and requests).
const customerLoader = new DataLoader(async (ids) => {
const rows = await db.customers.whereIn('id', ids);
return ids.map(id => rows.find(r => r.id === id)); // preserve input order; missing = undefined
});
// resolver:
Order.customer = (order) => customerLoader.load(order.customerId);Verify with a query log: a page-of-50-orders query should issue on the order of 2-3 SQL queries, not 51. Auditing an existing codebase for these is n-plus-one-hunter's job.
Step 5: Enforce query cost limits
- Depth limit: 8-10 for public APIs; first-party-only graphs can allow up to ~15. Anything deeper is either a malicious query or a client that should be paginating.
- Complexity/cost limit: assign each field a cost (scalar 1, object 2, list = child cost × requested page size) and reject queries over a budget in the low thousands of points, tuned so the heaviest legitimate client query passes with ~2x headroom.
- Reject at validation time, before execution - a rejected query should cost you parsing, not database load.
- For public APIs, add per-client rate limiting denominated in cost points, not request count, since one GraphQL request can equal 500 REST calls.
Step 6: Plan evolution and federation
- Version by evolving additively; deprecate with
@deprecated(reason: "use newField")and remove only after client traffic on the field hits zero. Never break a shipped field (deprecation rollout strategy: api-versioning-strategist). - Federation: split by subgraph ownership; use
@keyto define entity references; each subgraph owns its fields and the gateway composes. Keep entities resolvable by their key in every subgraph that extends them.
Step 7: Harden the edges
- Authorization per-field, not just at the query entry point - a nested path reaches any type the graph connects.
- Never expose raw database errors; map to typed, safe messages.
- Errors mid-list: return partial results with the
errorsarray rather than failing the whole response. - Caching: GraphQL-over-POST defeats HTTP caching - use persisted queries (also a security win: only known queries execute) or response caching keyed on query + variables.
Worked artifact: schema design, bad vs good
Bad - tables leaked into the schema, unbounded list, scalar foreign key, throw-only mutation:
type Query {
orders_tbl(user_id: Int): [OrderRow]
}
type OrderRow {
id: Int
status_code: Int # magic number, client must decode
customer_id: Int # scalar FK - client must make a second query
}
type Mutation {
updateOrder(id: Int, status: Int): Boolean # failures = thrown errors only
}Good - domain types, enum, object relationships, capped connection, error-carrying payload:
type Query {
order(id: ID!): Order
orders(first: Int! = 25, after: String): OrderConnection! # first capped at 100
}
type Order {
id: ID!
status: OrderStatus!
items: [LineItem!]!
customer: Customer! # object, resolved via DataLoader
}
enum OrderStatus { PENDING PAID SHIPPED }
type OrderConnection {
edges: [OrderEdge!]!
pageInfo: PageInfo!
}
type Mutation {
updateOrderStatus(input: UpdateOrderStatusInput!): UpdateOrderStatusPayload!
}
type UpdateOrderStatusPayload {
order: Order
userErrors: [UserError!]! # expected failures as data, not exceptions
}
type UserError { field: [String!], code: String!, message: String! }Deliverable
Produce the SDL schema plus a resolver plan listing: every relationship field with its DataLoader, the pagination caps per connection, the depth and complexity limits with the cost model, the authorization rule per sensitive field, and the deprecation policy for future changes.
Do NOT
- Do not mirror database tables into the schema - you freeze your storage layout into a public contract.
- Do not ship an unbounded list field; every list that can grow gets a connection with a capped page size.
- Do not resolve relationships row-by-row; no relationship resolver ships without a batch loader.
- Do not share DataLoader instances across requests - cross-user cache leakage.
- Do not model expected business failures as thrown GraphQL errors; use payload
userErrorsso clients can handle them typed. - Do not remove or retype a shipped field; deprecate additively and wait for zero traffic.
- Do not rely on entry-point auth; enforce per-field.
Quality bar
- Every type is a domain noun; no
_tbl,_id-scalar-FK, or status-code-integer smells remain. - Every list is a connection with an enforced page cap; depth and complexity limits are enabled and tested with a hostile deeply-nested query.
- A logged trace of the heaviest client query shows batched loads (single-digit queries per request).
- Every mutation returns a payload with
userErrors; every error path returns safe messages plus partial results where possible. - Federation entities resolve by
@keyfrom every extending subgraph.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

