pub type BeforeMutationEventFunc<RequestCtx> = fn(_: Value, _: EventFacade<'_, RequestCtx>) -> BoxFuture<'_, Result<Value, Error>>;
Expand description

Type alias for a function called before a mutation event. The Value returned by this function will be used as the input to the next before event function, or to the base Warpgrapher resolver if there are no more before event functions.

The structure of Value depends on the type of CRUD operation (which can be accessed via the op() method on EventFacade.) based on the list below:

CreateNode - Type>CreateMutationInput UpdateNode - <Type>UpdateInput DeleteNode - <Type>DeleteInput

You can refer to the generated GraphQL schema documentation for the data structures.

Examples


fn before_user_create(value: Value, ef: EventFacade<()>) -> BoxFuture<Result<Value, Error>> {
    Box::pin(async move {
        // Normally work would be done here, resulting in some new value.
        Ok(value)
    })
}