Skip to content

Commit

Permalink
Merge pull request #49 from michiel/feature/update-for-axum-deprecations
Browse files Browse the repository at this point in the history
chore: update deprecated axum struct
  • Loading branch information
sunli829 committed Mar 22, 2022
2 parents 61384c8 + 81abd07 commit 49451c2
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions axum/starwars/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use async_graphql_axum::{GraphQLRequest, GraphQLResponse};
use axum::extract::Extension;
use axum::response::{self, IntoResponse};
use axum::routing::get;
use axum::{AddExtensionLayer, Router, Server};
use axum::{Router, Server};
use starwars::{QueryRoot, StarWars, StarWarsSchema};

async fn graphql_handler(
Expand All @@ -26,7 +26,7 @@ async fn main() {

let app = Router::new()
.route("/", get(graphql_playground).post(graphql_handler))
.layer(AddExtensionLayer::new(schema));
.layer(Extension(schema));

println!("Playground: http://localhost:8000");

Expand Down
6 changes: 3 additions & 3 deletions axum/subscription/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ use async_graphql::Schema;
use async_graphql_axum::{GraphQLRequest, GraphQLResponse, GraphQLSubscription};
use axum::response::{self, IntoResponse};
use axum::routing::get;
use axum::{extract, AddExtensionLayer, Router, Server};
use axum::{extract::Extension, Router, Server};
use books::{BooksSchema, MutationRoot, QueryRoot, Storage, SubscriptionRoot};

async fn graphql_handler(
schema: extract::Extension<BooksSchema>,
schema: Extension<BooksSchema>,
req: GraphQLRequest,
) -> GraphQLResponse {
schema.execute(req.into_inner()).await.into()
Expand All @@ -28,7 +28,7 @@ async fn main() {
let app = Router::new()
.route("/", get(graphql_playground).post(graphql_handler))
.route("/ws", GraphQLSubscription::new(schema.clone()))
.layer(AddExtensionLayer::new(schema));
.layer(Extension(schema));

println!("Playground: http://localhost:8000");

Expand Down
4 changes: 2 additions & 2 deletions axum/upload/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use async_graphql_axum::{GraphQLRequest, GraphQLResponse};
use axum::extract::Extension;
use axum::response::{Html, IntoResponse};
use axum::routing::get;
use axum::{AddExtensionLayer, Router};
use axum::Router;
use files::{FilesSchema, MutationRoot, QueryRoot, Storage};
use hyper::{Method, Server};
use tower_http::cors::{CorsLayer, Origin};
Expand All @@ -27,7 +27,7 @@ async fn main() {

let app = Router::new()
.route("/", get(graphql_playground).post(graphql_handler))
.layer(AddExtensionLayer::new(schema))
.layer(Extension(schema))
.layer(
CorsLayer::new()
.allow_origin(Origin::predicate(|_, _| true))
Expand Down

0 comments on commit 49451c2

Please sign in to comment.