Expand description
A set of extensions for supporting Juniper integration.
§Examples
#[macro_use]
extern crate finchers;
extern crate finchers_juniper;
#[macro_use]
extern crate juniper;
use juniper::{EmptyMutation, RootNode};
// The contextual information used when GraphQL query executes.
//
// Typically it contains a connection retrieved from pool
// or credential information extracted from HTTP headers.
struct MyContext {
// ...
}
impl juniper::Context for MyContext {}
struct Query {}
graphql_object!(Query: MyContext |&self| {
field apiVersion() -> &str { "1.0" }
// ...
});
let schema = RootNode::new(
Query {},
EmptyMutation::<MyContext>::new(),
);
// An endpoint which acquires a GraphQL context from request.
let fetch_graphql_context =
endpoint::unit().map(|| MyContext { /* ... */ });
// Build an endpoint which handles GraphQL requests.
let endpoint = path!(@get / "graphql" /)
.and(fetch_graphql_context)
.wrap(finchers_juniper::execute::nonblocking(schema));Re-exports§
pub use graphiql::graphiql_source;pub use request::graphql_request;