Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support axum 0.7 #78

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions axum/starwars/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ edition = "2021"
[dependencies]
async-graphql = { path = "../../.." }
async-graphql-axum = { path = "../../../integrations/axum" }
tokio = { version = "1.8", features = ["macros", "rt-multi-thread"] }
tokio = { version = "1.34.0", features = ["macros", "rt-multi-thread"] }
starwars = { path = "../../models/starwars" }
hyper = "0.14"
axum = { version = "0.6.0", features = ["headers"] }
hyper = "1.0.1"
axum = { version = "0.7.1" }
7 changes: 4 additions & 3 deletions axum/starwars/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ use async_graphql_axum::GraphQL;
use axum::{
response::{self, IntoResponse},
routing::get,
Router, Server,
Router,
};
use tokio::net::TcpListener;
use starwars::{QueryRoot, StarWars};

async fn graphiql() -> impl IntoResponse {
Expand All @@ -21,8 +22,8 @@ async fn main() {

println!("GraphiQL IDE: http://localhost:8000");

Server::bind(&"127.0.0.1:8000".parse().unwrap())
.serve(app.into_make_service())
let listener = TcpListener::bind("127.0.0.1:8000").await.unwrap();
axum::serve(listener, app.into_make_service())
.await
.unwrap();
}
6 changes: 3 additions & 3 deletions axum/subscription/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ edition = "2021"
[dependencies]
async-graphql = { path = "../../.." }
async-graphql-axum = { path = "../../../integrations/axum" }
tokio = { version = "1.8", features = ["macros", "rt-multi-thread"] }
tokio = { version = "1.34.0", features = ["macros", "rt-multi-thread"] }
books = { path = "../../models/books" }
hyper = "0.14"
axum = { version = "0.6.0", features = ["ws", "headers"] }
hyper = "1.0.1"
axum = { version = "0.7.1", features = ["ws"] }
7 changes: 4 additions & 3 deletions axum/subscription/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ use async_graphql_axum::{GraphQL, GraphQLSubscription};
use axum::{
response::{self, IntoResponse},
routing::get,
Router, Server,
Router
};
use tokio::net::TcpListener;
use books::{MutationRoot, QueryRoot, Storage, SubscriptionRoot};

async fn graphiql() -> impl IntoResponse {
Expand All @@ -31,8 +32,8 @@ async fn main() {

println!("GraphiQL IDE: http://localhost:8000");

Server::bind(&"127.0.0.1:8000".parse().unwrap())
.serve(app.into_make_service())
let listener = TcpListener::bind("127.0.0.1:8000").await.unwrap();
axum::serve(listener, app.into_make_service())
.await
.unwrap();
}
6 changes: 3 additions & 3 deletions axum/token-from-header/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ edition = "2021"
[dependencies]
async-graphql = { path = "../../.." }
async-graphql-axum = { path = "../../../integrations/axum" }
tokio = { version = "1.8", features = ["macros", "rt-multi-thread"] }
tokio = { version = "1.34.0", features = ["macros", "rt-multi-thread"] }
token = { path = "../../models/token" }
hyper = "0.14"
axum = { version = "0.6.0", features = ["ws", "headers"] }
hyper = "1.0.1"
axum = { version = "0.7.1", features = ["ws"] }
7 changes: 4 additions & 3 deletions axum/token-from-header/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ use axum::{
http::header::HeaderMap,
response::{Html, IntoResponse, Response},
routing::get,
Router, Server,
Router,
};
use tokio::net::TcpListener;
use token::{on_connection_init, QueryRoot, SubscriptionRoot, Token, TokenSchema};

async fn graphql_playground() -> impl IntoResponse {
Expand Down Expand Up @@ -61,8 +62,8 @@ async fn main() {

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

Server::bind(&"127.0.0.1:8000".parse().unwrap())
.serve(app.into_make_service())
let listener = TcpListener::bind("127.0.0.1:8000").await.unwrap();
axum::serve(listener, app.into_make_service())
.await
.unwrap();
}
8 changes: 4 additions & 4 deletions axum/upload/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ edition = "2021"
[dependencies]
async-graphql = { path = "../../.." }
async-graphql-axum = { path = "../../../integrations/axum" }
axum = "0.6.0"
axum = "0.7.1"
files = { path = "../../models/files" }
tokio = { version = "1.8", features = ["macros", "rt-multi-thread"] }
hyper = "0.14"
tower-http = { version = "0.2.1", features = ["cors"] }
tokio = { version = "1.34.0", features = ["macros", "rt-multi-thread"] }
hyper = "1.0.1"
tower-http = { version = "0.5.0", features = ["cors"] }
11 changes: 6 additions & 5 deletions axum/upload/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ use axum::{
Router,
};
use files::{MutationRoot, QueryRoot, Storage};
use hyper::{Method, Server};
use tower_http::cors::{CorsLayer, Origin};
use hyper::Method;
use tower_http::cors::{CorsLayer, AllowOrigin};
use tokio::net::TcpListener;

async fn graphiql() -> impl IntoResponse {
Html(GraphiQLSource::build().endpoint("/").finish())
Expand All @@ -25,12 +26,12 @@ async fn main() {
.route("/", get(graphiql).post_service(GraphQL::new(schema)))
.layer(
CorsLayer::new()
.allow_origin(Origin::predicate(|_, _| true))
.allow_origin(AllowOrigin::predicate(|_, _| true))
.allow_methods(vec![Method::GET, Method::POST]),
);

Server::bind(&"127.0.0.1:8000".parse().unwrap())
.serve(app.into_make_service())
let listener = TcpListener::bind("127.0.0.1:8000").await.unwrap();
axum::serve(listener, app.into_make_service())
.await
.unwrap();
}