1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
// FIXME: remove this feature gate as soon as the rustc version used in docs.rs is updated #![cfg_attr(finchers_inject_extern_prelude, feature(extern_prelude))] //! A set of extensions for supporting Juniper integration. //! //! # Examples //! //! ``` //! #[macro_use] //! extern crate finchers; //! # use finchers::prelude::*; //! 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" } //! // ... //! }); //! //! # fn main() { //! 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)); //! # drop(move || { //! # finchers::server::start(endpoint).serve("127.0.0.1:4000") //! # }); //! # } //! ``` #![doc(html_root_url = "https://docs.rs/finchers-juniper/0.2.1")] #![warn( missing_docs, missing_debug_implementations, nonstandard_style, rust_2018_idioms, unused, )] // #![warn(rust_2018_compatibility)] #![cfg_attr(test, deny(warnings))] #![cfg_attr(test, doc(test(attr(deny(warnings)))))] extern crate bytes; extern crate failure; extern crate finchers; #[macro_use] extern crate futures; extern crate juniper; #[macro_use] extern crate log; extern crate percent_encoding; #[macro_use] extern crate serde; extern crate http; extern crate serde_json; extern crate serde_qs; #[cfg(test)] #[macro_use] extern crate matches; pub mod execute; pub mod graphiql; pub mod request; pub use graphiql::graphiql_source; pub use request::graphql_request;