Skip to content

Commit

Permalink
Update sea_orm 0.10
Browse files Browse the repository at this point in the history
  • Loading branch information
karatakis authored Nov 8, 2022
1 parent 04c3034 commit 77b2628
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 42 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }

Expand Down
4 changes: 2 additions & 2 deletions derive/src/root_query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<usize>,
current: Option<usize>
pages: Option<u64>,
current: Option<u64>
) -> async_graphql::types::connection::Connection<
String,
#path::Model,
Expand Down
2 changes: 1 addition & 1 deletion examples/mysql/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down
2 changes: 1 addition & 1 deletion examples/postgres/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down
4 changes: 2 additions & 2 deletions examples/sqlite/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ 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" }
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]
Expand Down
44 changes: 15 additions & 29 deletions examples/sqlite/src/main.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -25,22 +25,13 @@ lazy_static! {
});
}

type AppSchema = Schema<QueryRoot, EmptyMutation, EmptySubscription>;

async fn index(schema: web::Data<AppSchema>, req: GraphQLRequest) -> GraphQLResponse {
schema.execute(req.into_inner()).await.into()
}

async fn graphql_playground() -> Result<HttpResponse> {
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)
Expand All @@ -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");
}
2 changes: 1 addition & 1 deletion generator/src/templates/actix_cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ["<seaography-sql-library>", "runtime-async-std-native-tls"] }
sea-orm = { version = "^0.10", features = ["<seaography-sql-library>", "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" }
Expand Down
2 changes: 1 addition & 1 deletion generator/src/templates/poem_cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ["<seaography-sql-library>", "runtime-async-std-native-tls"] }
sea-orm = { version = "^0.10", features = ["<seaography-sql-library>", "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" }
Expand Down
8 changes: 4 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,8 @@ pub struct TypeFilter<T: async_graphql::InputType> {

#[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)]
Expand All @@ -224,8 +224,8 @@ pub enum Pagination {

#[derive(async_graphql::SimpleObject)]
pub struct ExtraPaginationFields {
pub pages: Option<usize>,
pub current: Option<usize>,
pub pages: Option<u64>,
pub current: Option<u64>,
}

#[derive(Debug)]
Expand Down

0 comments on commit 77b2628

Please sign in to comment.