Replace async-graphql with link to async-graphql's own examples (#1234)

* Replace async-graphql with link to async-graphql's own examples

* exclude async-graphql directory

* does this fix it?

* apparently this needs to be sorted as well

* Update .github/workflows/CI.yml

Co-authored-by: Jonas Platte <[email protected]>

Co-authored-by: Jonas Platte <[email protected]>
This commit is contained in:
David Pedersen
2022-08-09 14:56:50 +00:00
committed by GitHub
co-authored by Jonas Platte
parent ad7c8c5cdb
commit d9ef24c5ff
7 changed files with 6 additions and 416 deletions
-47
View File
@@ -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::Extension,
response::{Html, IntoResponse},
routing::get,
Json, Router,
};
use starwars::{QueryRoot, StarWars, StarWarsSchema};
async fn graphql_handler(schema: Extension<StarWarsSchema>, req: Json<Request>) -> Json<Response> {
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))
.layer(Extension(schema));
println!("Playground: http://localhost:3000");
axum::Server::bind(&"0.0.0.0:3000".parse().unwrap())
.serve(app.into_make_service())
.await
.unwrap();
}