pub fn resolver(&self, name: &str) -> Result<&ResolverFunc<RequestCtx>, Error> {
        self.resolvers
            .get(name)
            .map(|b| b.as_ref())
            .ok_or_else(|| Error::ResolverNotFound {
                name: name.to_owned(),
            })
    }
/// Takes the name of a custom resolver and returns the function implementing that resolver
///
/// # Errors
///
/// Returns an [`Error`] variant [`ResolverNotFound`] if the context does not contain a
/// resolver function associated with the name argument
///
/// [`Error`]: ../../enum.Error.html
/// [`ResolverNotFound`]: ../../enum.Error.html#variant.ResolverNotFound
///
/// # Examples
///
/// ```rust,no_run
/// # #[cfg(feature = "neo4j")]
/// use bolt_proto::Message;
/// use std::collections::HashMap;
/// use std::iter::FromIterator;
/// # use tokio::main;
/// # use warpgrapher::engine::context::RequestContext;
/// # #[cfg(feature = "neo4j")]
/// # use warpgrapher::engine::database::{DatabaseEndpoint, DatabasePool, Transaction, QueryResult};
/// # #[cfg(feature = "neo4j")]
/// # use warpgrapher::engine::database::neo4j::Neo4jEndpoint;
/// # use warpgrapher::engine::resolvers::{Resolvers, ResolverFacade};
/// # use warpgrapher::engine::validators::Validators;
/// # use warpgrapher::engine::context::GraphQLContext;
/// # use warpgrapher::engine::resolvers::ExecutionResult;
/// # use warpgrapher::juniper::BoxFuture;
/// # use warpgrapher::engine::events::EventHandlerBag;
/// # use warpgrapher::Error;
///
/// # #[derive(Clone, Debug)]
/// # pub struct AppCtx {}
///
/// # #[cfg(feature = "neo4j")]
/// # impl RequestContext for AppCtx {
/// #    type DBEndpointType = Neo4jEndpoint;
/// #    fn new() -> Self {AppCtx{}}
/// # }
///
/// # #[cfg(feature = "neo4j")]
/// pub fn project_count(facade: ResolverFacade<AppCtx>) -> BoxFuture<ExecutionResult> {
///     Box::pin(async move {
///         let mut transaction = facade.executor().context().pool().transaction().await?;
///         transaction.begin().await?;
///         let query = "MATCH (n:Project) RETURN (n)".to_string();
///         let qr = transaction.execute_query::<AppCtx>(query, HashMap::new()).await?;
///
///         if let QueryResult::Neo4j(records) = qr {
///             transaction.commit().await?;
///             std::mem::drop(transaction);
///             facade.resolve_scalar(records.len() as i32)
///         } else {
///             transaction.rollback().await?;
///             Err(warpgrapher::Error::TypeNotExpected { details: None }.into())
///         }
///     })
/// }
///
/// # #[tokio::main]
/// # async fn main() -> Result<(), Box<dyn std::error::Error>> {
/// # #[cfg(feature = "neo4j")]
/// let mut resolvers: Resolvers<AppCtx> = Resolvers::new();
/// # #[cfg(feature = "neo4j")]
/// resolvers.insert("ProjectCount".to_string(), Box::new(project_count));
///
/// # #[cfg(feature = "neo4j")]
/// let ne = Neo4jEndpoint::from_env()?;
/// let validators: Validators = Validators::new();
/// # #[cfg(feature = "neo4j")]
/// let gqlctx: GraphQLContext<AppCtx> = GraphQLContext::new(
///     ne.pool().await?,
///     resolvers,
///     validators,
///     EventHandlerBag::<AppCtx>::new(),
///     Some(AppCtx::new()),
///     None,
///     HashMap::new()
/// );
///
/// # #[cfg(feature = "neo4j")]
/// let gqlctx = gqlctx.resolver("CustomResolver");
/// # Ok(())
/// # }
/// ```
Takes the name of a custom resolver and returns the function implementing that resolver
Takes the name of a custom resolver and returns the function implementing that resolver
pub fn resolver(&self, name: &str) -> Result<&ResolverFunc<RequestCtx>, Error> {
        self.resolvers
            .get(name)
            .map(|b| b.as_ref())
            .ok_or_else(|| Error::ResolverNotFound {
                name: name.to_owned(),
            })
    }
pub fn resolver ( & self , name : & str ) -> Result < & ResolverFunc < RequestCtx > , Error > { self . resolvers . get ( name ) . map ( | b | b . as_ref ( ) ) . ok_or_else ( | | Error :: ResolverNotFound { name : name . to_owned ( ) , } ) }
Takes the name of a custom resolver and returns the function implementing that resolver
Takes the name of a custom resolver and returns the function implementing that resolver
&self
name
&str
&self
name
&str
errors
Returns an [`Error`] variant [`ResolverNotFound`] if the context does not contain a
resolver function associated with the name argument

[`Error`]: ../../enum.Error.html
[`ResolverNotFound`]: ../../enum.Error.html#variant.ResolverNotFound
Returns an [ ` Error ` ] variant [ ` ResolverNotFound ` ] if the context does not contain a resolver function associated with the name argument [ ` Error ` ] : .. / .. / enum . Error . html [ ` ResolverNotFound ` ] : .. / .. / enum . Error . html#variant . ResolverNotFound
examples
None
#[cfg(feature = "neo4j")]
use bolt_proto::Message;
use std::collections::HashMap;
use std::iter::FromIterator.
use bolt_proto :: Message ; use std :: collections :: HashMap ; use std :: iter :: FromIterator .
use tokio::main;
None
use warpgrapher::engine::context::requestcontext;
None
#[cfg(feature = "neo4j")]
None
use warpgrapher::engine::database::{databaseendpoint, databasepool, transaction, queryresult};
None
#[cfg(feature = "neo4j")]
None
use warpgrapher::engine::database::neo4j::neo4jendpoint;
None
use warpgrapher::engine::resolvers::{resolvers, resolverfacade};
None
use warpgrapher::engine::validators::validators;
None
use warpgrapher::engine::context::graphqlcontext;
None
use warpgrapher::engine::resolvers::executionresult;
None
use warpgrapher::juniper::boxfuture;
None
use warpgrapher::engine::events::eventhandlerbag;
None
use warpgrapher::error;
None
#[derive(clone, debug)]
None
pub struct appctx {}
None
#[cfg(feature = "neo4j")]
None
impl requestcontext for appctx {
None
type dbendpointtype = neo4jendpoint;
None
fn new() -> self {appctx{}}
None
}
None
#[cfg(feature = "neo4j")]
pub fn project_count(facade: ResolverFacade) -> BoxFuture {
Box::pin(async move {
let mut transaction = facade.executor().context().pool().transaction().await?;
transaction.begin().await?;
let query = "MATCH (n:Project) RETURN (n)".to_string();
let qr = transaction.execute_query::(query, HashMap::new()).await?.

if let QueryResult::Neo4j(records) = qr {
transaction.commit().await?;
std::mem::drop(transaction);
facade.resolve_scalar(records.len() as i32)
} else {
transaction.rollback().await?;
Err(warpgrapher::Error::TypeNotExpected { details: None }.into())
}
})
}
pub fn project_count ( facade : ResolverFacade ) - > BoxFuture { Box :: pin ( async move { let mut transaction = facade . executor () . context () . pool () . transaction () . await? ; transaction . begin () . await? ; let query = " MATCH ( n : Project ) RETURN ( n ) " . to_string () ; let qr = transaction . execute_query :: ( query HashMap :: new () ) . await? . if let QueryResult :: Neo4j ( records ) = qr { transaction . commit () . await? ; std :: mem :: drop ( transaction ) ; facade . resolve_scalar ( records . len () as i32 ) } else { transaction . rollback () . await? ; Err ( warpgrapher :: Error :: TypeNotExpected { details : None } . into () ) } } ) }
#[tokio::main]
None
async fn main() -> result<(), box<dyn std::error::error>> {
None
#[cfg(feature = "neo4j")]
let mut resolvers: Resolvers = Resolvers::new().
let mut resolvers : Resolvers = Resolvers :: new () .
#[cfg(feature = "neo4j")]
None
#[cfg(feature = "neo4j")]
let ne = Neo4jEndpoint::from_env()?;
let validators: Validators = Validators::new().
let ne = Neo4jEndpoint :: from_env () ? ; let validators : Validators = Validators :: new () .
#[cfg(feature = "neo4j")]
let gqlctx: GraphQLContext = GraphQLContext::new(
ne.pool().await?,
resolvers,
validators,
EventHandlerBag::::new(),
Some(AppCtx::new()),
None,
HashMap::new()
).
let gqlctx : GraphQLContext = GraphQLContext :: new ( ne . pool () . await? resolvers validators EventHandlerBag :::: new () Some ( AppCtx :: new () ) None HashMap :: new () ) .
#[cfg(feature = "neo4j")]
let gqlctx = gqlctx.resolver("CustomResolver").
let gqlctx = gqlctx . resolver ( " CustomResolver " ) .
ok(())
None
}
None