[][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

Full Example


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

struct QueryRoot;

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

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