pub struct EventFacade<'a, RequestCtx> where
    RequestCtx: RequestContext
{ /* private fields */ }
Expand description

Provides a simplified interface to utility operations inside an event handler.

Implementations

Returns the context of the GraphQL request which in turn contains the application-defined request context.

Returns the context of the GraphQL request which in turn contains the application-defined request context.

Provides an abstracted database read operation using warpgrapher inputs. This is the recommended way to read data in a database-agnostic way that ensures the event handlers are portable across different databases.

Arguments
  • type_name - String reference represing name of node type (ex: “User”).
  • input - Optional Value describing which node to match. Same input structure passed to a READ crud operation (<Type>QueryInput).
  • partition_key_opt - Optional Value describing the partition key if the underlying database supports it.
Examples

fn before_user_read(value: Value, mut ef: EventFacade<()>) -> BoxFuture<Result<Value, Error>> {
    Box::pin(async move {
        let nodes_to_be_read = ef.read_nodes("User", value.clone(), None).await?;
        // modify value before passing it forward ...
        Ok(value)
    })
}

Provides an abstracted database create operation using warpgrapher inputs. This is the recommended way to create nodes in a database-agnostic way that ensures the event handlers are portable across different databases.

Arguments
  • type_name - String reference represing name of node type (ex: “User”).
  • input - Value describing the node to create.
  • partition_key_opt - Optional Value describing the partition key if the underlying database supports it.
Examples

fn before_user_read(value: Value, mut ef: EventFacade<()>) -> BoxFuture<Result<Value, Error>> {
    Box::pin(async move {
        let new_node = ef.create_node("Team", value.clone(), None).await?;
        Ok(value)
    })
}

Provides an abstracted database update operation using warpgrapher inputs. This is the recommended way to create nodes in a database-agnostic way that ensures the event handlers are portable across different databases.

Arguments
  • type_name - String reference represing name of node type (ex: “User”).
  • input - Value describing the node to update.
  • partition_key_opt - Optional Value describing the partition key if the underlying database supports it.
Examples

fn before_user_read(value: Value, mut ef: EventFacade<()>) -> BoxFuture<Result<Value, Error>> {
    Box::pin(async move {
        let new_node = ef.update_node(
            "User",
            json!({
                "MATCH": {"name": {"EQ": "alice"}},
                "SET": {"name": "eve"}
            }),
            None).await?;
        Ok(value)
    })
}

Provides an abstracted database delete operation using warpgrapher inputs. This is the recommended way to create nodes in a database-agnostic way that ensures the event handlers are portable across different databases.

Arguments
  • type_name - String reference represing name of node type (ex: “User”).
  • input - Value describing the node to update.
  • partition_key_opt - Optional Value describing the partition key if the underlying database supports it.
Examples

fn before_user_read(value: Value, mut ef: EventFacade<()>) -> BoxFuture<Result<Value, Error>> {
    Box::pin(async move {
        let new_node = ef.delete_node(
            "User",
            json!({
                "MATCH": {"name": {"EQ": "alice"}}
            }),
            None).await?;
        Ok(value)
    })
}

Provides an abstracted database rel read operation using warpgrapher inputs. This is the recommended way to read relationships in a database-agnostic way that ensures the event handlers are portable across different databases.

Arguments
  • src_node_label - String reference represing name of node type (ex: “User”).
  • rel_label - String reference representing the name of the relationship (ex: “teams”).
  • input - Value describing the relationship query input.
  • partition_key_opt - Optional Value describing the partition key if the underlying database supports it.
Examples

fn before_user_read(value: Value, mut ef: EventFacade<()>) -> BoxFuture<Result<Value, Error>> {
    Box::pin(async move {
        let rels: Vec<Rel<()>> = ef.read_rels(
            "User",
            "teams",
            json!({
                "src": {"name": {"EQ": "alice"}}
            }),
            None).await?;
        Ok(value)
    })
}

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more