pub struct Engine<RequestCtx = ()> where
    RequestCtx: RequestContext
{ /* private fields */ }
Expand description

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, NoDatabasePool {}).build()?;

Implementations

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, NoDatabasePool {}).build()?;

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, NoDatabasePool {}).build()?;

let query = "query { name }".to_string();
let metadata: HashMap<String, String> = HashMap::new();

let result = engine.execute(query, None, metadata).await?;

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more