pub async fn read_nodes(
        rf: &ResolverFacade<'_, RequestCtx>,
        type_name: &str,
        input: impl TryInto<Value>,
        partition_key_opt: Option<&Value>,
        transaction: &'a mut <<<RequestCtx as RequestContext>::DBEndpointType as DatabaseEndpoint>::PoolType as DatabasePool>::TransactionType,
    ) -> Result<Vec<Node<RequestCtx>>, Error> {
        let mut info = rf.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,
            transaction,
        )
        .await?;
        let results = transaction
            .read_nodes(&node_var, query_fragment, partition_key_opt, &info)
            .await;
        results
    }
/// Provides an abstracted database node 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 serde_json::json;
/// # use warpgrapher::Error;
/// # use warpgrapher::engine::database::{DatabasePool, Transaction};
/// # use warpgrapher::engine::resolvers::{ResolverFacade, ExecutionResult};
/// # use warpgrapher::engine::value::Value;
/// # use warpgrapher::juniper::BoxFuture;
///
/// fn custom_resolve(mut facade: ResolverFacade<()>) -> BoxFuture<ExecutionResult> {
///     Box::pin(async move {
///         let mut transaction = facade.executor().context().pool().transaction().await?;
///         transaction.begin().await?;
///
///         let result = ResolverFacade::read_nodes(&facade, "User", json!({"name": "alice"}),
///             None, &mut transaction).await?;
///         let alice = result.first().unwrap();
///
///         transaction.commit().await?;
///         std::mem::drop(transaction);
///
///         facade.resolve_node(&alice).await
///     })
/// }
/// ```
Provides an abstracted database node 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 node 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(
        rf: &ResolverFacade<'_, RequestCtx>,
        type_name: &str,
        input: impl TryInto<Value>,
        partition_key_opt: Option<&Value>,
        transaction: &'a mut <<<RequestCtx as RequestContext>::DBEndpointType as DatabaseEndpoint>::PoolType as DatabasePool>::TransactionType,
    ) -> Result<Vec<Node<RequestCtx>>, Error> {
        let mut info = rf.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,
            transaction,
        )
        .await?;
        let results = transaction
            .read_nodes(&node_var, query_fragment, partition_key_opt, &info)
            .await;
        results
    }
pub async fn read_nodes ( rf : & ResolverFacade < ' _ , RequestCtx > , type_name : & str , input : impl TryInto < Value > , partition_key_opt : Option < & Value > , transaction : & ' a mut < < < RequestCtx as RequestContext > :: DBEndpointType as DatabaseEndpoint > :: PoolType as DatabasePool > :: TransactionType , ) -> Result < Vec < Node < RequestCtx > > , Error > { let mut info = rf . 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 , transaction , ) . await ? ; let results = transaction . read_nodes ( & node_var , query_fragment , partition_key_opt , & info ) . await ; results }
Provides an abstracted database node read operation using warpgrapher inputs.
Provides an abstracted database node read operation using warpgrapher inputs .
rf
&ResolverFacade<'_, RequestCtx>
type_name
&str
input
impl TryInto<Value>
partition_key_opt
Option<&Value>
transaction
&'a mut <<<RequestCtx as RequestContext>::DBEndpointType as DatabaseEndpoint>::PoolType as DatabasePool>::TransactionType
rf
&ResolverFacade<'_, RequestCtx>
type_name
&str
input
impl TryInto<Value>
partition_key_opt
Option<&Value>
transaction
&'a mut <<<RequestCtx as RequestContext>::DBEndpointType as DatabaseEndpoint>::PoolType as DatabasePool>::TransactionType
examples
None
use serde_json::json;
None
use warpgrapher::error;
None
use warpgrapher::engine::database::{databasepool, transaction};
None
use warpgrapher::engine::resolvers::{resolverfacade, executionresult};
None
use warpgrapher::engine::value::value;
None
use warpgrapher::juniper::boxfuture;
fn custom_resolve(mut facade: ResolverFacade<()>) -> BoxFuture {
Box::pin(async move {
let mut transaction = facade.executor().context().pool().transaction().await?;
transaction.begin().await?.

let result = ResolverFacade::read_nodes(&facade, "User", json!({"name": "alice"}),
None, &mut transaction).await?;
let alice = result.first().unwrap().

transaction.commit().await?;
std::mem::drop(transaction).

facade.resolve_node(&alice).await
})
}
```
fn custom_resolve ( mut facade : ResolverFacade< () > ) - > BoxFuture { Box :: pin ( async move { let mut transaction = facade . executor () . context () . pool () . transaction () . await? ; transaction . begin () . await? . let result = ResolverFacade :: read_nodes ( &facade " User " json! ( { " name " : " alice " } ) None &mut transaction ) . await? ; let alice = result . first () . unwrap () . transaction . commit () . await? ; std :: mem :: drop ( transaction ) . facade . resolve_node ( &alice ) . await } ) } ` ` `