[−][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, Reply}; use std::convert::Infallible; use async_graphql::http::GQLResponse; 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 { 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; }