#[mutation]Expand description
Marks a function as a mutation (transactional write).
Mutations run within a database transaction. All changes commit together or roll back on error.
§Authentication
By default, mutations require an authenticated user. Override with:
public- No authentication requiredrequire_role("admin")- Require specific role
§Attributes
log- Enable logging for this mutationtimeout = 30- Timeout in seconds
§Example
ⓘ
#[forge::mutation] // Requires authenticated user (default)
pub async fn create_project(ctx: &MutationContext, input: CreateProjectInput) -> Result<Project> {
let user_id = ctx.require_user_id()?;
// ...
}
#[forge::mutation(public)] // No auth required
pub async fn submit_feedback(ctx: &MutationContext, input: FeedbackInput) -> Result<()> {
// ...
}
#[forge::mutation(require_role("admin"), log)]
pub async fn delete_user(ctx: &MutationContext, user_id: Uuid) -> Result<()> {
// Requires admin role
}