[−][src]Struct warpgrapher::engine::EngineBuilder
Implements the builder pattern for Warpgrapher engines
Examples
let config = Configuration::default(); let engine = Engine::<(), ()>::new(config, DatabasePool::NoDatabase).build()?;
Implementations
impl<GlobalCtx, RequestCtx> EngineBuilder<GlobalCtx, RequestCtx> where
GlobalCtx: GlobalContext,
RequestCtx: RequestContext,
[src]
GlobalCtx: GlobalContext,
RequestCtx: RequestContext,
pub fn with_global_ctx(
self,
global_ctx: GlobalCtx
) -> EngineBuilder<GlobalCtx, RequestCtx>
[src]
self,
global_ctx: GlobalCtx
) -> EngineBuilder<GlobalCtx, RequestCtx>
Adds a global context to the engine
Examples
#[derive(Clone, Debug)] pub struct AppGlobalCtx { global_var: String } impl GlobalContext for AppGlobalCtx {} let global_ctx = AppGlobalCtx { global_var: "Hello World".to_string() }; let config = Configuration::default(); let mut engine = Engine::<AppGlobalCtx, ()>::new(config, DatabasePool::NoDatabase) .with_global_ctx(global_ctx) .build()?;
pub fn with_resolvers(
self,
resolvers: Resolvers<GlobalCtx, RequestCtx>
) -> EngineBuilder<GlobalCtx, RequestCtx>
[src]
self,
resolvers: Resolvers<GlobalCtx, RequestCtx>
) -> EngineBuilder<GlobalCtx, RequestCtx>
Adds resolvers to the engine
Examples
let resolvers = Resolvers::<(), ()>::new(); let config = Configuration::default(); let mut engine = Engine::<(), ()>::new(config, DatabasePool::NoDatabase) .with_resolvers(resolvers) .build()?;
pub fn with_validators(
self,
validators: Validators
) -> EngineBuilder<GlobalCtx, RequestCtx>
[src]
self,
validators: Validators
) -> EngineBuilder<GlobalCtx, RequestCtx>
Adds validators to the engine
Examples
let validators = Validators::new(); let config = Configuration::default(); let mut engine = Engine::<(), ()>::new(config, DatabasePool::NoDatabase) .with_validators(validators) .build()?;
pub fn with_extensions(
self,
extensions: Extensions<GlobalCtx, RequestCtx>
) -> EngineBuilder<GlobalCtx, RequestCtx>
[src]
self,
extensions: Extensions<GlobalCtx, RequestCtx>
) -> EngineBuilder<GlobalCtx, RequestCtx>
Adds extensions to engine
Examples
let extensions = Extensions::<(), ()>::new(); let config = Configuration::default(); let mut engine = Engine::<(), ()>::new(config, DatabasePool::NoDatabase) .with_extensions(extensions) .build()?;
pub fn with_version(
self,
version: String
) -> EngineBuilder<GlobalCtx, RequestCtx>
[src]
self,
version: String
) -> EngineBuilder<GlobalCtx, RequestCtx>
Sets the version of the app
Examples
let config = Configuration::default(); let mut engine = Engine::<(), ()>::new(config, DatabasePool::NoDatabase) .with_version("1.0.0".to_string()) .build()?;
pub fn build(self) -> Result<Engine<GlobalCtx, RequestCtx>, Error>
[src]
Builds a configured Engine
including generating the data model, CRUD operations, and
custom endpoints from the Configuration
c
. Returns the Engine
.
Errors
Returns an Error
variant ConfigItemDuplicated
if there is more than one type or
more than one endpoint that use the same name.
Returns an Error
variant ConfigItemReserved
if a named configuration item, such as
an endpoint or type, has a name that is a reserved word, such as "ID" or the name of a
GraphQL scalar type.
Returns an Error
variant SchemaItemNotFound
if there is an error in the
configuration, specifically if the configuration of type A references type B, but type B
cannot be found.
Returns an Error
variant ResolverNotFound
if there is a resolver defined in the
configuration for which no ResolverFunc
has been added to the Resolvers
collection
applied to the EngineBuilder with with_resolvers
.
Returns an Error
variant ValidatorNotFound
if there is a validator defined in the
configuration for which no ValidatorFunc
has been added to the Validators
collection
applied to the EngineBuilder with with_validators
.
Returns an
Examples
let config = Configuration::new(1, Vec::new(), Vec::new()); let mut engine = Engine::<()>::new(config, DatabasePool::NoDatabase).build()?;
Trait Implementations
impl<GlobalCtx: Clone, RequestCtx: Clone> Clone for EngineBuilder<GlobalCtx, RequestCtx> where
GlobalCtx: GlobalContext,
RequestCtx: RequestContext,
[src]
GlobalCtx: GlobalContext,
RequestCtx: RequestContext,
fn clone(&self) -> EngineBuilder<GlobalCtx, RequestCtx>
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for EngineBuilder
[src]
impl<GlobalCtx: Default, RequestCtx: Default> Default for EngineBuilder<GlobalCtx, RequestCtx> where
GlobalCtx: GlobalContext,
RequestCtx: RequestContext,
[src]
GlobalCtx: GlobalContext,
RequestCtx: RequestContext,
fn default() -> EngineBuilder<GlobalCtx, RequestCtx>
[src]
Auto Trait Implementations
impl<GlobalCtx = (), RequestCtx = ()> !RefUnwindSafe for EngineBuilder<GlobalCtx, RequestCtx>
impl<GlobalCtx, RequestCtx> Send for EngineBuilder<GlobalCtx, RequestCtx>
impl<GlobalCtx, RequestCtx> Sync for EngineBuilder<GlobalCtx, RequestCtx>
impl<GlobalCtx, RequestCtx> Unpin for EngineBuilder<GlobalCtx, RequestCtx> where
GlobalCtx: Unpin,
GlobalCtx: Unpin,
impl<GlobalCtx = (), RequestCtx = ()> !UnwindSafe for EngineBuilder<GlobalCtx, RequestCtx>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T> Instrument for T
[src]
fn instrument(self, span: Span) -> Instrumented<Self>
[src]
fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T> Instrument for T
[src]
fn instrument(self, span: Span) -> Instrumented<Self>
[src]
fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,