pub async fn read_nodes(
        &mut self,
        type_name: &str,
        input: impl TryInto<Value>,
        partition_key_opt: Option<&Value>,
    ) -> Result<Vec<Node<RequestCtx>>, Error> {
        let mut info = self.info.clone();
        info.name = "Query".to_string();

        let mut sg = SuffixGenerator::new();
        let node_var =
            NodeQueryVar::new(Some(type_name.to_string()), "node".to_string(), sg.suffix());

        let query_fragment = visit_node_query_input::<RequestCtx>(
            &node_var,
            Some(input.try_into().map_err(|_e| Error::TypeConversionFailed {
                src: "".to_string(),
                dst: "".to_string(),
            })?),
            &Info::new(
                format!("{}QueryInput", type_name.to_string()),
                info.type_defs(),
            ),
            partition_key_opt,
            &mut sg,
            self.transaction,
        )
        .await?;

        let results = self
            .transaction
            .read_nodes(&node_var, query_fragment, partition_key_opt, &info)
            .await;
        results
    }
/// 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
///
/// ```rust, no_run
/// # 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 nodes_to_be_read = ef.read_nodes("User", value.clone(), None).await?;
///         // modify value before passing it forward ...
///         Ok(value)
///     })
/// }
/// ```
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.
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 .
pub async fn read_nodes(
        &mut self,
        type_name: &str,
        input: impl TryInto<Value>,
        partition_key_opt: Option<&Value>,
    ) -> Result<Vec<Node<RequestCtx>>, Error> {
        let mut info = self.info.clone();
        info.name = "Query".to_string();
        let mut sg = SuffixGenerator::new();
        let node_var =
            NodeQueryVar::new(Some(type_name.to_string()), "node".to_string(), sg.suffix());
        let query_fragment = visit_node_query_input::<RequestCtx>(
            &node_var,
            Some(input.try_into().map_err(|_e| Error::TypeConversionFailed {
                src: "".to_string(),
                dst: "".to_string(),
            })?),
            &Info::new(
                format!("{}QueryInput", type_name.to_string()),
                info.type_defs(),
            ),
            partition_key_opt,
            &mut sg,
            self.transaction,
        )
        .await?;
        let results = self
            .transaction
            .read_nodes(&node_var, query_fragment, partition_key_opt, &info)
            .await;
        results
    }
pub async fn read_nodes ( & mut self , type_name : & str , input : impl TryInto < Value > , partition_key_opt : Option < & Value > , ) -> Result < Vec < Node < RequestCtx > > , Error > { let mut info = self . info . clone ( ) ; info . name = " " . to_string ( ) ; let mut sg = SuffixGenerator :: new ( ) ; let node_var = NodeQueryVar :: new ( Some ( type_name . to_string ( ) ) , " " . to_string ( ) , sg . suffix ( ) ) ; let query_fragment = visit_node_query_input :: < RequestCtx > ( & node_var , Some ( input . try_into ( ) . map_err ( | _e | Error :: TypeConversionFailed { src : " " . to_string ( ) , dst : " " . to_string ( ) , } ) ? ) , & Info :: new ( format ! ( " " type_name to_string ( ) ) , info . type_defs ( ) , ) , partition_key_opt , & mut sg , self . transaction , ) . await ? ; let results = self . transaction . read_nodes ( & node_var , query_fragment , partition_key_opt , & info ) . await ; results }
Provides an abstracted database read operation using warpgrapher inputs.
Provides an abstracted database read 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 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 nodes_to_be_read = ef.read_nodes("User", value.clone(), None).await?;
modify value before passing it forward
Ok(value)
})
}
```
fn before_user_read ( value : Value mut ef : EventFacade< () > ) - > BoxFuture > { 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 ) } ) } ` ` `