ForgeMutation

Trait ForgeMutation 

Source
pub trait ForgeMutation:
    Send
    + Sync
    + 'static {
    type Args: DeserializeOwned + Serialize + Send + Sync;
    type Output: Serialize + Send;

    // Required methods
    fn info() -> FunctionInfo;
    fn execute(
        ctx: &MutationContext,
        args: Self::Args,
    ) -> Pin<Box<dyn Future<Output = Result<Self::Output>> + Send + '_>>;
}
Expand description

A mutation function (transactional write).

Mutations:

  • Run within a database transaction
  • Can read and write to the database
  • Should NOT call external APIs (use Actions)
  • Are atomic: all changes commit or none do

Required Associated Types§

Source

type Args: DeserializeOwned + Serialize + Send + Sync

The input arguments type.

Source

type Output: Serialize + Send

The output type.

Required Methods§

Source

fn info() -> FunctionInfo

Function metadata.

Source

fn execute( ctx: &MutationContext, args: Self::Args, ) -> Pin<Box<dyn Future<Output = Result<Self::Output>> + Send + '_>>

Execute the mutation within a transaction.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§