Struct warpgrapher::engine::EngineBuilder
source · [−]pub struct EngineBuilder<RequestCtx = ()> where
RequestCtx: RequestContext, { /* private fields */ }
Expand description
Implements the builder pattern for Warpgrapher engines
Examples
let config = Configuration::default();
let engine = Engine::<()>::new(config, NoDatabasePool {}).build()?;
Implementations
sourceimpl<RequestCtx> EngineBuilder<RequestCtx> where
RequestCtx: RequestContext,
impl<RequestCtx> EngineBuilder<RequestCtx> where
RequestCtx: RequestContext,
sourcepub fn with_resolvers(
self,
resolvers: Resolvers<RequestCtx>
) -> EngineBuilder<RequestCtx>
pub fn with_resolvers(
self,
resolvers: Resolvers<RequestCtx>
) -> EngineBuilder<RequestCtx>
Adds resolvers to the engine
Examples
let resolvers = Resolvers::<()>::new();
let config = Configuration::default();
let mut engine = Engine::<()>::new(config, NoDatabasePool {})
.with_resolvers(resolvers)
.build()?;
sourcepub fn with_validators(
self,
validators: Validators
) -> EngineBuilder<RequestCtx>
pub fn with_validators(
self,
validators: Validators
) -> EngineBuilder<RequestCtx>
Adds validators to the engine
Examples
let validators = Validators::new();
let config = Configuration::default();
let mut engine = Engine::<()>::new(config, NoDatabasePool {})
.with_validators(validators)
.build()?;
sourcepub fn with_event_handlers(
self,
event_handlers: EventHandlerBag<RequestCtx>
) -> EngineBuilder<RequestCtx>
pub fn with_event_handlers(
self,
event_handlers: EventHandlerBag<RequestCtx>
) -> EngineBuilder<RequestCtx>
Adds event handlers to the engine
Examples
let event_handlers = EventHandlerBag::<()>::new();
let config = Configuration::default();
let mut engine = Engine::<()>::new(config, NoDatabasePool {})
.with_event_handlers(event_handlers)
.build()?;
sourcepub fn with_version(self, version: String) -> EngineBuilder<RequestCtx>
pub fn with_version(self, version: String) -> EngineBuilder<RequestCtx>
Sets the version of the app
Examples
let config = Configuration::default();
let mut engine = Engine::<()>::new(config, NoDatabasePool {})
.with_version("1.0.0".to_string())
.build()?;
sourcepub fn build(self) -> Result<Engine<RequestCtx>, Error>
pub fn build(self) -> Result<Engine<RequestCtx>, Error>
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, NoDatabasePool {}).build()?;
Trait Implementations
sourceimpl<RequestCtx: Clone> Clone for EngineBuilder<RequestCtx> where
RequestCtx: RequestContext,
impl<RequestCtx: Clone> Clone for EngineBuilder<RequestCtx> where
RequestCtx: RequestContext,
sourcefn clone(&self) -> EngineBuilder<RequestCtx>
fn clone(&self) -> EngineBuilder<RequestCtx>
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
Auto Trait Implementations
impl<RequestCtx> RefUnwindSafe for EngineBuilder<RequestCtx> where
<<RequestCtx as RequestContext>::DBEndpointType as DatabaseEndpoint>::PoolType: RefUnwindSafe,
impl<RequestCtx> Send for EngineBuilder<RequestCtx>
impl<RequestCtx> Sync for EngineBuilder<RequestCtx>
impl<RequestCtx> Unpin for EngineBuilder<RequestCtx> where
<<RequestCtx as RequestContext>::DBEndpointType as DatabaseEndpoint>::PoolType: Unpin,
impl<RequestCtx> UnwindSafe for EngineBuilder<RequestCtx> where
<<RequestCtx as RequestContext>::DBEndpointType as DatabaseEndpoint>::PoolType: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
pub fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more