pub async fn update_node(
        &mut self,
        type_name: &str,
        input: impl TryInto<Value>,
        partition_key_opt: Option<&Value>,
    ) -> Result<Vec<Node<RequestCtx>>, Error> {
        let mut sg = SuffixGenerator::new();
        let node_var =
            NodeQueryVar::new(Some(type_name.to_string()), "node".to_string(), sg.suffix());
        let result = visit_node_update_input(
            &node_var,
            input.try_into().map_err(|_e| Error::TypeConversionFailed {
                src: "".to_string(),
                dst: "".to_string(),
            })?,
            &Info::new(
                format!("{}UpdateInput", type_name.to_string()),
                self.info.type_defs(),
            ),
            partition_key_opt,
            &mut sg,
            self.transaction,
            self.context(),
        )
        .await;
        result
    }
/// 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
///
/// ```rust, no_run
/// # use serde_json::json;
/// # use warpgrapher::Error;
/// # use warpgrapher::engine::events::EventFacade;
/// # use warpgrapher::engine::value::Value;
/// # use warpgrapher::juniper::BoxFuture;
///
/// 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 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.
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 .
pub async fn update_node(
        &mut self,
        type_name: &str,
        input: impl TryInto<Value>,
        partition_key_opt: Option<&Value>,
    ) -> Result<Vec<Node<RequestCtx>>, Error> {
        let mut sg = SuffixGenerator::new();
        let node_var =
            NodeQueryVar::new(Some(type_name.to_string()), "node".to_string(), sg.suffix());
        let result = visit_node_update_input(
            &node_var,
            input.try_into().map_err(|_e| Error::TypeConversionFailed {
                src: "".to_string(),
                dst: "".to_string(),
            })?,
            &Info::new(
                format!("{}UpdateInput", type_name.to_string()),
                self.info.type_defs(),
            ),
            partition_key_opt,
            &mut sg,
            self.transaction,
            self.context(),
        )
        .await;
        result
    }
pub async fn update_node ( & mut self , type_name : & str , input : impl TryInto < Value > , partition_key_opt : Option < & Value > , ) -> Result < Vec < Node < RequestCtx > > , Error > { let mut sg = SuffixGenerator :: new ( ) ; let node_var = NodeQueryVar :: new ( Some ( type_name . to_string ( ) ) , " " . to_string ( ) , sg . suffix ( ) ) ; let result = visit_node_update_input ( & node_var , input . try_into ( ) . map_err ( | _e | Error :: TypeConversionFailed { src : " " . to_string ( ) , dst : " " . to_string ( ) , } ) ? , & Info :: new ( format ! ( " " type_name to_string ( ) ) , self . info . type_defs ( ) , ) , partition_key_opt , & mut sg , self . transaction , self . context ( ) , ) . await ; result }
Provides an abstracted database update operation using warpgrapher inputs.
Provides an abstracted database update operation using warpgrapher inputs .
&mut self
type_name
&str
input
impl TryInto<Value>
partition_key_opt
Option<&Value>
&mut self
type_name
&str
input
impl TryInto<Value>
partition_key_opt
Option<&Value>
examples
None
use serde_json::json;
None
use warpgrapher::error;
None
use warpgrapher::engine::events::eventfacade;
None
use warpgrapher::engine::value::value;
None
use warpgrapher::juniper::boxfuture;
fn before_user_read(value: Value, mut ef: EventFacade<()>) -> BoxFuture> {
Box::pin(async move {
let new_node = ef.update_node(
"User",
json!({
"MATCH": {"name": {"EQ": "alice"}},
"SET": {"name": "eve"}
}),
None).await?;
Ok(value)
})
}
```
fn before_user_read ( value : Value mut ef : EventFacade< () > ) - > BoxFuture > { Box :: pin ( async move { let new_node = ef . update_node ( " User " json! ( { " MATCH " : { " name " : { " EQ " : " alice " }} " SET " : { " name " : " eve " } } ) None ) . await? ; Ok ( value ) } ) } ` ` `