[][src]Struct warpgrapher::engine::Engine

pub struct Engine<GlobalCtx = (), RequestCtx = ()> where
    GlobalCtx: GlobalContext,
    RequestCtx: RequestContext
{ /* fields omitted */ }

A Warpgrapher GraphQL engine.

The Engine struct Juniper GraphQL service on top of it, with an auto-generated set of resolvers that cover basic CRUD operations, and potentially custom resolvers, on a set of data types and the relationships between them. The engine includes handling of back-end communications with the chosen databse.

Examples


let config = Configuration::default();

let mut engine = Engine::<(), ()>::new(config, DatabasePool::NoDatabase).build()?;

Implementations

impl<GlobalCtx, RequestCtx> Engine<GlobalCtx, RequestCtx> where
    GlobalCtx: GlobalContext,
    RequestCtx: RequestContext
[src]

pub fn new(
    config: Configuration,
    database_pool: DatabasePool
) -> EngineBuilder<GlobalCtx, RequestCtx>
[src]

Creates a new EngineBuilder. Requiered arguments are a Configuration, the deserialized configuration for a Warpgrapher engine, which contains definitions of types and endpoints, as well as a DatabasePool, which tells the ending how to connect with a back-end graph storage engine.

Examples


let config = Configuration::default();

let mut engine = Engine::<(), ()>::new(config, DatabasePool::NoDatabase).build()?;

pub fn execute(
    &self,
    req: &GraphQLRequest,
    metadata: &HashMap<String, String>
) -> Result<Value, Error>
[src]

Executes a GraphQLRequest, returning a serialized JSON response.

Errors

Returns an Error variant ExtensionFailed if a pre request hook or post request hook extension returns an error.

Returns an Error variant [SerializationFailed] if the engine response cannot be serialized successfully.

Examples


let config = Configuration::default();
let mut engine = Engine::<(), ()>::new(config, DatabasePool::NoDatabase).build()?;

let metadata: HashMap<String, String> = HashMap::new();
let req_body = json!({"query": "query { name }"});

let result = engine.execute(&from_value::<GraphQLRequest>(req_body)?, &metadata)?;

Trait Implementations

impl<GlobalCtx: Clone, RequestCtx: Clone> Clone for Engine<GlobalCtx, RequestCtx> where
    GlobalCtx: GlobalContext,
    RequestCtx: RequestContext
[src]

impl<GlobalCtx, RequestCtx> Debug for Engine<GlobalCtx, RequestCtx> where
    GlobalCtx: GlobalContext,
    RequestCtx: RequestContext
[src]

impl<GlobalCtx, RequestCtx> Display for Engine<GlobalCtx, RequestCtx> where
    GlobalCtx: GlobalContext,
    RequestCtx: RequestContext
[src]

Auto Trait Implementations

impl<GlobalCtx = (), RequestCtx = ()> !RefUnwindSafe for Engine<GlobalCtx, RequestCtx>

impl<GlobalCtx, RequestCtx> Send for Engine<GlobalCtx, RequestCtx>

impl<GlobalCtx, RequestCtx> Sync for Engine<GlobalCtx, RequestCtx>

impl<GlobalCtx, RequestCtx> Unpin for Engine<GlobalCtx, RequestCtx> where
    GlobalCtx: Unpin

impl<GlobalCtx = (), RequestCtx = ()> !UnwindSafe for Engine<GlobalCtx, RequestCtx>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T> Instrument for T[src]

impl<T> Instrument for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,