From 3d31bcb6fba0b6a9b6fad8c90f53522ab78a2928 Mon Sep 17 00:00:00 2001 From: David Pedersen Date: Sun, 8 Jan 2023 16:28:45 +0100 Subject: [PATCH] Remove lingering async-graphql example file It should have been deleted previously --- examples/async-graphql/src/main.rs | 47 ------------------------------ 1 file changed, 47 deletions(-) delete mode 100644 examples/async-graphql/src/main.rs diff --git a/examples/async-graphql/src/main.rs b/examples/async-graphql/src/main.rs deleted file mode 100644 index 6dd4cc2c..00000000 --- a/examples/async-graphql/src/main.rs +++ /dev/null @@ -1,47 +0,0 @@ -//! Example async-graphql application. -//! -//! Run with -//! -//! ```not_rust -//! cd examples && cargo run -p example-async-graphql -//! ``` - -mod starwars; - -use async_graphql::{ - http::{playground_source, GraphQLPlaygroundConfig}, - EmptyMutation, EmptySubscription, Request, Response, Schema, -}; -use axum::{ - extract::State, - response::{Html, IntoResponse}, - routing::get, - Json, Router, -}; -use starwars::{QueryRoot, StarWars, StarWarsSchema}; - -async fn graphql_handler(schema: State, req: Json) -> Json { - schema.execute(req.0).await.into() -} - -async fn graphql_playground() -> impl IntoResponse { - Html(playground_source(GraphQLPlaygroundConfig::new("/"))) -} - -#[tokio::main] -async fn main() { - let schema = Schema::build(QueryRoot, EmptyMutation, EmptySubscription) - .data(StarWars::new()) - .finish(); - - let app = Router::new() - .route("/", get(graphql_playground).post(graphql_handler)) - .with_state(schema); - - println!("Playground: http://localhost:3000"); - - axum::Server::bind(&"0.0.0.0:3000".parse().unwrap()) - .serve(app.into_make_service()) - .await - .unwrap(); -}