forgex 0.10.2

CLI and runtime for the Forge full-stack framework
Documentation
// Context API: let mut conn = ctx.conn().await?; ctx.user_id()?; ctx.dispatch_job(...).
// Add `transactional` if you dispatch jobs / start workflows from this mutation.

use forge::prelude::*;

#[forge::mutation /* (transactional) */]
pub async fn {{name}}(ctx: &MutationContext, input: serde_json::Value) -> Result<serde_json::Value> {
    let user_id = ctx.user_id()?;
    let mut conn = ctx.conn().await?;
    let _ = (&mut conn, &input);

    // TODO: replace with the actual write, e.g.
    // sqlx::query!(
    //     "INSERT INTO your_table (user_id, payload) VALUES ($1, $2)",
    //     user_id,
    //     input,
    // )
    // .execute(&mut *conn)
    // .await?;

    Ok(serde_json::json!({ "ok": true, "user": user_id }))
}