diff --git a/Cargo.toml b/Cargo.toml index 4840c907..99a8964d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ categories = ["database"] [dependencies] async-graphql = { version = "4.0.12", default-features = false } seaography-derive = { version = "^0.2.0", path = "./derive" } -sea-orm = { version = "^0.9", default-features = false } +sea-orm = { version = "^0.10", default-features = false } itertools = { version = "0.10.3" } heck = { version = "0.4.0" } diff --git a/derive/src/root_query.rs b/derive/src/root_query.rs index 1f992d22..af6dbe5f 100644 --- a/derive/src/root_query.rs +++ b/derive/src/root_query.rs @@ -103,8 +103,8 @@ pub fn basic_query(name: &Ident, path: &TokenStream) -> TokenStream { data: Vec<#path::Model>, has_previous_page: bool, has_next_page: bool, - pages: Option, - current: Option + pages: Option, + current: Option ) -> async_graphql::types::connection::Connection< String, #path::Model, diff --git a/examples/mysql/Cargo.toml b/examples/mysql/Cargo.toml index 5de46a61..5cca2797 100644 --- a/examples/mysql/Cargo.toml +++ b/examples/mysql/Cargo.toml @@ -9,7 +9,7 @@ async-graphql-poem = { version = "4.0.10" } async-trait = { version = "0.1.53" } dotenv = "0.15.0" poem = { version = "1.3.29" } -sea-orm = { version = "^0.9", features = ["sqlx-mysql", "runtime-async-std-native-tls"] } +sea-orm = { version = "^0.10", features = ["sqlx-mysql", "runtime-async-std-native-tls"] } tokio = { version = "1.17.0", features = ["macros", "rt-multi-thread"] } tracing = { version = "0.1.34" } tracing-subscriber = { version = "0.3.11" } diff --git a/examples/postgres/Cargo.toml b/examples/postgres/Cargo.toml index 568a247b..91cfa964 100644 --- a/examples/postgres/Cargo.toml +++ b/examples/postgres/Cargo.toml @@ -9,7 +9,7 @@ async-graphql-poem = { version = "4.0.10" } async-trait = { version = "0.1.53" } dotenv = "0.15.0" poem = { version = "1.3.29" } -sea-orm = { version = "^0.9", features = ["sqlx-postgres", "runtime-async-std-native-tls"] } +sea-orm = { version = "^0.10", features = ["sqlx-postgres", "runtime-async-std-native-tls"] } tokio = { version = "1.17.0", features = ["macros", "rt-multi-thread"] } tracing = { version = "0.1.34" } tracing-subscriber = { version = "0.3.11" } diff --git a/examples/sqlite/Cargo.toml b/examples/sqlite/Cargo.toml index d36916c6..aa573250 100644 --- a/examples/sqlite/Cargo.toml +++ b/examples/sqlite/Cargo.toml @@ -9,7 +9,7 @@ async-graphql = { version = "4.0.14", features = ["decimal", "chrono", "dataload async-graphql-poem = { version = "4.0.14" } async-trait = { version = "0.1.53" } dotenv = "0.15.0" -sea-orm = { version = "^0.9", features = ["sqlx-sqlite", "runtime-async-std-native-tls"] } +sea-orm = { version = "^0.10", features = ["sqlx-sqlite", "runtime-async-std-native-tls"] } tokio = { version = "1.17.0", features = ["macros", "rt-multi-thread"] } tracing = { version = "0.1.34" } tracing-subscriber = { version = "0.3.11" } @@ -17,7 +17,7 @@ lazy_static = { version = "1.4.0" } [dependencies.seaography] path = "../../" # remove this line in your own project -version = "^0.2" # seaography version +version = "^0.2.0" # seaography version features = ["with-decimal", "with-chrono"] [dev-dependencies] diff --git a/examples/sqlite/src/main.rs b/examples/sqlite/src/main.rs index fcc7285a..ef1db8a3 100644 --- a/examples/sqlite/src/main.rs +++ b/examples/sqlite/src/main.rs @@ -1,12 +1,12 @@ -use actix_web::{guard, web, web::Data, App, HttpResponse, HttpServer, Result}; use async_graphql::{ dataloader::DataLoader, http::{playground_source, GraphQLPlaygroundConfig}, EmptyMutation, EmptySubscription, Schema, }; -use async_graphql_actix_web::{GraphQLRequest, GraphQLResponse}; +use async_graphql_poem::GraphQL; use dotenv::dotenv; use lazy_static::lazy_static; +use poem::{get, handler, listener::TcpListener, web::Html, IntoResponse, Route, Server}; use sea_orm::Database; use seaography_sqlite_example::*; use std::env; @@ -25,22 +25,13 @@ lazy_static! { }); } -type AppSchema = Schema; - -async fn index(schema: web::Data, req: GraphQLRequest) -> GraphQLResponse { - schema.execute(req.into_inner()).await.into() -} - -async fn graphql_playground() -> Result { - Ok(HttpResponse::Ok() - .content_type("text/html; charset=utf-8") - .body(playground_source(GraphQLPlaygroundConfig::new( - "http://localhost:8000", - )))) +#[handler] +async fn graphql_playground() -> impl IntoResponse { + Html(playground_source(GraphQLPlaygroundConfig::new(&*ENDPOINT))) } -#[actix_web::main] -async fn main() -> std::io::Result<()> { +#[tokio::main] +async fn main() { dotenv().ok(); tracing_subscriber::fmt() .with_max_level(tracing::Level::INFO) @@ -65,18 +56,13 @@ async fn main() -> std::io::Result<()> { schema = schema.limit_complexity(complexity); } let schema = schema.finish(); + let app = Route::new().at( + &*ENDPOINT, + get(graphql_playground).post(GraphQL::new(schema)), + ); println!("Visit GraphQL Playground at http://{}", *URL); - HttpServer::new(move || { - App::new() - .app_data(Data::new(schema.clone())) - .service(web::resource("/").guard(guard::Post()).to(index)) - .service( - web::resource("/") - .guard(guard::Get()) - .to(graphql_playground), - ) - }) - .bind("127.0.0.1:8000")? - .run() - .await + Server::new(TcpListener::bind(&*URL)) + .run(app) + .await + .expect("Fail to start web server"); } diff --git a/generator/src/templates/actix_cargo.toml b/generator/src/templates/actix_cargo.toml index ec99ebbe..2f7e9688 100644 --- a/generator/src/templates/actix_cargo.toml +++ b/generator/src/templates/actix_cargo.toml @@ -9,7 +9,7 @@ async-graphql = { version = "4.0.14", features = ["decimal", "chrono", "dataload async-graphql-actix-web = { version = "4.0.14" } async-trait = { version = "0.1.53" } dotenv = "0.15.0" -sea-orm = { version = "^0.9", features = ["", "runtime-async-std-native-tls"] } +sea-orm = { version = "^0.10", features = ["", "runtime-async-std-native-tls"] } tokio = { version = "1.17.0", features = ["macros", "rt-multi-thread"] } tracing = { version = "0.1.34" } tracing-subscriber = { version = "0.3.11" } diff --git a/generator/src/templates/poem_cargo.toml b/generator/src/templates/poem_cargo.toml index 4fbf1679..0b00a093 100644 --- a/generator/src/templates/poem_cargo.toml +++ b/generator/src/templates/poem_cargo.toml @@ -9,7 +9,7 @@ async-graphql = { version = "4.0.14", features = ["decimal", "chrono", "dataload async-graphql-poem = { version = "4.0.14" } async-trait = { version = "0.1.53" } dotenv = "0.15.0" -sea-orm = { version = "^0.9", features = ["", "runtime-async-std-native-tls"] } +sea-orm = { version = "^0.10", features = ["", "runtime-async-std-native-tls"] } tokio = { version = "1.17.0", features = ["macros", "rt-multi-thread"] } tracing = { version = "0.1.34" } tracing-subscriber = { version = "0.3.11" } diff --git a/src/lib.rs b/src/lib.rs index c016848e..64f4fff3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -206,8 +206,8 @@ pub struct TypeFilter { #[derive(Debug, async_graphql::InputObject)] pub struct PageInput { - pub limit: usize, - pub page: usize, + pub limit: u64, + pub page: u64, } #[derive(Debug, async_graphql::InputObject)] @@ -224,8 +224,8 @@ pub enum Pagination { #[derive(async_graphql::SimpleObject)] pub struct ExtraPaginationFields { - pub pages: Option, - pub current: Option, + pub pages: Option, + pub current: Option, } #[derive(Debug)]