new-gql-operation
Skill0 starsChanged 8 months agoMITView on GitHub
Scaffold a GraphQL operation file (.graphql) and trigger codegen. Use when the user asks to write a GraphQL query, mutation, or subscription for use in a Vue component or composable.
In this repository10 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- design-componentSkill
- new-componentSkill
- new-composableSkill
- new-migrationSkill
- new-quill-fieldSkill
- new-resolverSkill
- new-server-routeSkill
- new-settings-storeSkill
- new-storeSkill
The file
We split this skill into the rules it gives an agent
7 rules. About 0 are common, 2 are distinctive, and 5 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
5
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- could be automatic: a setting could enforce it
- Very specific: line 10
Place alongside the composable that uses them: composables/usePost.graphql
- Very specific: line 12
After creating/editing: run npm run codegen to regenerate ~/types/gql.ts
- Very specific: line 13
Import the document in the composable: import MyDocument from './myComposable.graphql'
- Distinctive: line 14
Use fragments for reused field sets
- Very specific: line 101
Ask: what entity, what operations (query/mutation/both)?
- Very specific: line 102
Check server/graphql/schema/ to see available fields
- Distinctive: line 105
Import the generated types in the composable
≈ “Common” is an estimate: at least 1 in 5 of the 364,980 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 GQL Operation
Rules
- Operation files use
.graphqlextension - Place alongside the composable that uses them:
composables/usePost.graphql - Operation name must be unique across the whole codebase (codegen requirement)
- After creating/editing: run
npm run codegento regenerate~/types/gql.ts - Import the document in the composable:
import MyDocument from './myComposable.graphql' - Use fragments for reused field sets
Query Template
# composables/use[Type].graphql
query Get[Type]($id: ID!) {
get[Type](id: $id) {
id
# ... fields
createdAt
updatedAt
}
}
query List[Type]s($limit: Int, $offset: Int) {
list[Type]s(limit: $limit, offset: $offset) {
id
# ... fields
}
}Mutation Template
# composables/use[Type]Mutations.graphql
mutation Create[Type]($input: Create[Type]Input!) {
create[Type](input: $input) {
id
# ... fields
}
}
mutation Update[Type]($id: ID!, $input: Update[Type]Input!) {
update[Type](id: $id, input: $input) {
id
# ... fields
}
}
mutation Delete[Type]($id: ID!) {
delete[Type](id: $id)
}Fragment Template (for reuse)
fragment [Type]Fields on [Type] {
id
name
createdAt
updatedAt
}
query Get[Type]($id: ID!) {
get[Type](id: $id) {
...[Type]Fields
}
}Usage in Composable After Codegen
// composables/use[Type].ts
import type { Get[Type]Query, Get[Type]QueryVariables } from '~/types/gql'
import Get[Type]Document from './use[Type].graphql'
export function use[Type](id: MaybeRef<string>) {
const { data, pending, error, refresh } = useAsyncQuery<Get[Type]Query>(
Get[Type]Document,
computed(() => ({ id: unref(id) }) satisfies Get[Type]QueryVariables)
)
return {
[type]: computed(() => data.value?.get[Type] ?? null),
isLoading: pending,
error,
refresh,
}
}Steps
- Ask: what entity, what operations (query/mutation/both)?
- Check
server/graphql/schema/to see available fields - Generate the
.graphqlfile alongside the composable - Run:
npm run codegen - Import the generated types in the composable
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.

