[][src]Function async_graphql_warp::graphql

pub fn graphql<Query, Mutation, Subscription>(
    schema: Schema<Query, Mutation, Subscription>
) -> BoxedFilter<((Schema<Query, Mutation, Subscription>, QueryBuilder),)> where
    Query: ObjectType + Send + Sync + 'static,
    Mutation: ObjectType + Send + Sync + 'static,
    Subscription: SubscriptionType + Send + Sync + 'static, 

GraphQL request filter

It outputs a tuple containing the Schema and QuertBuilder.

Examples


use async_graphql::*;
use warp::Filter;
use std::convert::Infallible;

struct QueryRoot;

#[Object]
impl QueryRoot {
    #[field]
    async fn value(&self, ctx: &Context<'_>) -> i32 {
        unimplemented!()
    }
}

let schema = Schema::new(QueryRoot, EmptyMutation, EmptySubscription);
let filter = async_graphql_warp::graphql(schema).and_then(|schema, builder| async move {
    let resp = builder.execute(&schema).await;
    Ok::<_, Infallible>(warp::reply::json(&GQLResponse(resp)).into_response())
});
warp::serve(filter).run(([0, 0, 0, 0], 8000)).await;