7 releases

Uses old Rust 2015

0.2.1 Oct 15, 2018
0.2.0 Oct 9, 2018
0.1.1 Oct 2, 2018
0.1.0 Sep 30, 2018

#27 in #juniper

24 downloads per month

MIT/Apache

35KB
785 lines

finchers-juniper

crates.io Docs.rs dependency status Build Status Coverage Status

A set of extensions for integrating Juniper endpoints.

License

MIT license or Apache License, Version 2.0 at your option.


lib.rs:

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));

Dependencies

~22MB
~433K SLoC