/major-ai-skills:graphql-apisfrom major-ai-skills
Design production GraphQL schemas and resolvers with field-level authz, per-request DataLoader batching, cursor pagination, depth/complexity limits, and safe schema evolution.
Ships in major-ai-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
GraphQL exposes a typed schema (types, queries, mutations, subscriptions) where clients select fields. The runtime parses → validates → executes resolvers. Naive per-field DB access causes N+1 query fan-out. Agents design schemas for product use cases, enforce authz in resolvers/fields, batch with per-request DataLoaders, paginate lists, and harden public graphs with depth/complexity limits and optional persisted/allowlisted operations.
┌─────────────────────────────────────────────────────────────┐
│ GraphQL request path │
│ │
│ Client operation (+ variables, operation name) │
│ ├── parse / validate (depth · complexity · auth directives)│
│ └── execute field resolvers │
│ │
│ Context (per request) │
│ ├── user / auth principal │
│ ├── DataLoaders (request-scoped only) │
│ └── services / @prisma / DB │
│ │
│ Hardening │
│ └── pagination · error masking · persisted queries (opt) │
└─────────────────────────────────────────────────────────────┘
Use when
@express, @nodejs, @nextjs (Route Handlers), or other HTTP hosts.Do not use when
@express REST.@prisma / @postgresql.@deprecated before removal.Promise.all / parallel field resolution).first/last.type User {
id: ID!
email: String!
}
type Item {
id: ID!
sku: String!
qty: Int!
owner: User!
}
type ItemConnection {
edges: [ItemEdge!]!
pageInfo: PageInfo!
}
type ItemEdge {
cursor: String!
node: Item!
}
type PageInfo {
hasNextPage: Boolean!
endCursor: String
}
type Query {
item(id: ID!): Item
items(first: Int = 20, after: String): ItemConnection!
}
type Mutation {
createItem(sku: String!, qty: Int!): Item!
}
import DataLoader from "dataloader";
type User = { id: string; email: string };
type Item = { id: string; sku: string; qty: number; ownerId: string };
function createLoaders(db: Db) {
return {
userById: new DataLoader<string, User>(async (ids) => {
const rows = await db.usersByIds([...ids]); // single WHERE id IN (…)
const map = new Map(rows.map((u) => [u.id, u]));
return ids.map((id) => map.get(id) ?? new Error(`User ${id} not found`));
}),
};
}
export function buildContext({ req, db }: { req: Req; db: Db }) {
const user = requireUserFromAuthHeader(req); // throws/unauth → GraphQL error
return { user, db, loaders: createLoaders(db) };
}
export const resolvers = {
Query: {
item: async (_: unknown, { id }: { id: string }, ctx: Ctx) => {
const item = await ctx.db.itemById(id);
if (!item) return null;
await assertCanReadItem(ctx.user, item);
return item;
},
items: async (_: unknown, args: { first?: number; after?: string }, ctx: Ctx) => {
const first = Math.min(args.first ?? 20, 100);
return ctx.db.listItemsConnection({ first, after: args.after, viewer: ctx.user });
},
},
Item: {
owner: (item: Item, _: unknown, ctx: Ctx) => ctx.loaders.userById.load(item.ownerId),
},
Mutation: {
createItem: async (_: unknown, args: { sku: string; qty: number }, ctx: Ctx) => {
ctx.requireUser();
if (args.qty < 0) throw new UserInputError("qty must be >= 0");
return ctx.db.createItem({ ...args, ownerId: ctx.user.id });
},
},
};
Host examples: Yoga/Apollo on @express/@nodejs; App Router handlers on @nextjs. Persist data with @prisma. Validate schema changes in CI (GraphQL Code Generator, Apollo Rover graph check, or equivalent).
npm run codegen
# schema registry (when used):
npx rover graph check my-graph@current --schema ./schema.graphql
| Signature | Likely cause | Fix path |
|---|---|---|
| DB QPS explodes on one GraphQL op | N+1 field resolvers | Per-request DataLoader; join/batch in service |
| Loader cache leaks auth data | Global/singleton DataLoader | Create loaders inside context per request |
| Batch mis-aligned nulls/errors | Batch fn not keyed-order | Map results back to ids order |
| Auth only at gateway; field leaks | Missing resolver checks | Field/type authz; test nested selections |
| Huge payloads / timeouts | Unbounded lists | Cursor pagination + max page size |
| Depth/cost rejects valid ops | Estimator counts fragments/nesting aggressively | Tune limits; align with planner/fragments (esp. federation) |
| Breaking client after deploy | Removed/renamed fields | Additive evolution + @deprecated |
| Internal stack traces to clients | Unmasked errors in prod | Error masking; log server-side with operation name |
@prisma select/take—GraphQL does not magically limit SQL.@express / @nodejs / @nextjs — HTTP hosts for GraphQL servers@prisma — typed DB access behind resolvers@postgresql — database performance and indexes under resolver load@typescript — resolver/context typing and codegen@docker — local API + DB compose stacksMANDATORY: Authz on sensitive resolvers. Per-request DataLoaders with key-ordered batches. Paginate and cost-limit public graphs. Evolve schemas additively. Never invent credentials or ship unrestricted public introspection without an explicit threat model.
What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub alivirgo/major-ai-skills --plugin major-ai-skills412 skills in this plugin
/3d-slicerAutomate 3D Slicer research workflows with MRML, VTK/ITK, DICOM data, and Segment Editor. Use for software workflows, not clinical interpretation./abbreviated-git-statusInspect Git branch, staging, and working-tree changes with short or porcelain status output when a compact repository check is needed./ableton-liveAutomate Ableton Live sessions with Python MIDI Remote Scripts, Max for Live, AbletonOSC, and Link synchronization./act-as-a-personal-tutorExplain a subject step by step, assess prior knowledge, and use short exercises to check understanding before advancing.Other plugins' skills for the same job