[−][src]Function async_graphql_tide::graphql
pub async fn graphql<Query, Mutation, Subscription, TideState, F>(
req: Request<TideState>,
schema: Schema<Query, Mutation, Subscription>,
query_builder_configuration: F
) -> Result<Response> where
Query: ObjectType + Send + Sync + 'static,
Mutation: ObjectType + Send + Sync + 'static,
Subscription: SubscriptionType + Send + Sync + 'static,
TideState: Send + Sync + 'static,
F: Fn(QueryBuilder) -> QueryBuilder,
GraphQL request handler
Examples
use async_graphql::*; use async_std::task; use tide::Request; struct QueryRoot; #[Object] impl QueryRoot { #[field(desc = "Returns the sum of a and b")] async fn add(&self, a: i32, b: i32) -> i32 { a + b } } fn main() -> std::result::Result<(), Box<dyn std::error::Error + Send + Sync>> { task::block_on(async { let mut app = tide::new(); app.at("/").post(|req: Request<()>| async move { let schema = Schema::build(QueryRoot, EmptyMutation, EmptySubscription).finish(); async_graphql_tide::graphql(req, schema, |query_builder| query_builder).await }); app.listen("0.0.0.0:8000").await?; Ok(()) }) }