Skip to content

Commit af32ac3

Browse files
authored
add mutation conventions (#141)
* add mutation conventions * trunk updates
1 parent 4d420e8 commit af32ac3

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

modus/api-generation.mdx

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,3 +138,29 @@ function classify(text: string, threshold: f32): ClassifierResult[] {
138138

139139
</Tab>
140140
</Tabs>
141+
142+
## Generating mutations
143+
144+
By default, all exported functions are generated as GraphQL **queries** unless
145+
they follow specific naming conventions that indicate they perform mutations
146+
(data modifications).
147+
148+
Functions are automatically classified as **mutations** when they start with
149+
these prefixes:
150+
151+
- `mutate`
152+
- `post`, `patch`, `put`, `delete`
153+
- `add`, `update`, `insert`, `upsert`
154+
- `create`, `edit`, `save`, `remove`, `alter`, `modify`
155+
156+
For example:
157+
158+
- `getUserById` → Query
159+
- `listProducts` → Query
160+
- `addUser` → Mutation
161+
- `updateProduct` → Mutation
162+
- `deleteOrder` → Mutation
163+
164+
The prefix is detected precisely - `addPost` becomes a mutation, but
165+
`additionalPosts` remains a query since "additional" doesn't match the exact
166+
"add" prefix pattern.

0 commit comments

Comments
 (0)