new-resolver
Skill0 starsChanged 8 months agoMITView on GitHub
Scaffold a new GraphQL Yoga resolver with Drizzle ORM query. Use when the user asks to create a GraphQL query, mutation, resolver, or any server-side data operation.
In this repository10 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- design-componentSkill
- new-componentSkill
- new-composableSkill
- new-gql-operationSkill
- new-migrationSkill
- new-quill-fieldSkill
- new-server-routeSkill
- new-settings-storeSkill
- new-storeSkill
The file
We split this skill into the rules it gives an agent
4 rules. About 0 are common, 1 is distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 11
Always protect with requireUserSession(event) unless explicitly public
- Very specific: line 12
Always use Drizzle returning() after insert/update instead of a second select
- Distinctive: line 91
Ask: what domain/entity? What operations are needed (CRUD or specific)?
- Very specific: line 92
Check server/db/schema/ for the existing Drizzle table definition
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Skill: New Resolver
Rules
- Resolvers live in
server/graphql/resolvers/[domain].ts - Types are inferred from Drizzle — never redefined manually
- Always protect with
requireUserSession(event)unless explicitly public - Always use Drizzle
returning()after insert/update instead of a second select - Handle errors with typed throws
- Export a resolver map object, imported and merged in
server/api/graphql.ts
Resolver Template
// server/graphql/resolvers/[domain].ts
import { db } from '../db'
import { [table] } from '../db/schema/[domain]'
import { eq, desc } from 'drizzle-orm'
import type { [Type], New[Type] } from '../db/schema/[domain]'
import type { H3Event } from 'h3'
interface Context {
event: H3Event
user?: { id: string }
}
export const [domain]Resolvers = {
Query: {
get[Type]: async (_: unknown, { id }: { id: string }, ctx: Context): Promise<[Type]> => {
await requireUserSession(ctx.event)
const result = await db
.select()
.from([table])
.where(eq([table].id, id))
.limit(1)
if (!result[0]) throw new Error('[Type] not found')
return result[0]
},
list[Type]s: async (_: unknown, _args: unknown, ctx: Context): Promise<[Type][]> => {
await requireUserSession(ctx.event)
return db.select().from([table]).orderBy(desc([table].createdAt))
},
},
Mutation: {
create[Type]: async (
_: unknown,
{ input }: { input: New[Type] },
ctx: Context
): Promise<[Type]> => {
await requireUserSession(ctx.event)
const result = await db.insert([table]).values(input).returning()
return result[0]
},
update[Type]: async (
_: unknown,
{ id, input }: { id: string; input: Partial<New[Type]> },
ctx: Context
): Promise<[Type]> => {
await requireUserSession(ctx.event)
const result = await db
.update([table])
.set({ ...input, updatedAt: new Date() })
.where(eq([table].id, id))
.returning()
if (!result[0]) throw new Error('[Type] not found')
return result[0]
},
delete[Type]: async (
_: unknown,
{ id }: { id: string },
ctx: Context
): Promise<boolean> => {
await requireUserSession(ctx.event)
const result = await db.delete([table]).where(eq([table].id, id)).returning()
return result.length > 0
},
},
}Steps
- Ask: what domain/entity? What operations are needed (CRUD or specific)?
- Check
server/db/schema/for the existing Drizzle table definition - Generate resolver following the template
- Remind: also add corresponding GraphQL type definitions in
server/graphql/schema/ - Remind: merge resolver into the root resolver in
server/api/graphql.ts - Remind: run
npm run codegento regenerate types
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.

