-
-
Notifications
You must be signed in to change notification settings - Fork 526
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
37 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,23 @@ | ||
[package] | ||
edition = "2021" | ||
name = "sea-orm-seaography-example" | ||
version = "0.3.0" | ||
publish = false | ||
version = "0.1.0" | ||
|
||
[dependencies] | ||
poem = { version = "3.0" } | ||
async-graphql-poem = { version = "7.0" } | ||
async-graphql = { version = "7.0", features = ["decimal", "chrono", "dataloader", "dynamic-schema"] } | ||
async-trait = { version = "0.1.72" } | ||
dotenv = "0.15.0" | ||
sea-orm = { path = "../../../", features = ["sqlx-mysql", "runtime-async-std-native-tls", "seaography"] } | ||
sea-orm = { version = "~1.1.4", features = ["sqlx-mysql", "runtime-async-std-native-tls", "seaography"] } | ||
tokio = { version = "1.29.1", features = ["macros", "rt-multi-thread"] } | ||
tracing = { version = "0.1.37" } | ||
tracing-subscriber = { version = "0.3.17" } | ||
lazy_static = { version = "1.4.0" } | ||
seaography = { version = "1.1.0", features = ["with-decimal", "with-chrono"] } | ||
|
||
[dependencies.seaography] | ||
version = "~1.1.3" # seaography version | ||
features = ["with-decimal", "with-chrono"] | ||
|
||
[dev-dependencies] | ||
serde_json = { version = "1.0.103" } | ||
|
||
[workspace] | ||
members = [] | ||
|
||
# This allows us to develop using a local version of sea-orm | ||
# remove this section in your own project | ||
[patch.crates-io] | ||
sea-orm = { path = "../../../" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,2 @@ | ||
use sea_orm::prelude::*; | ||
|
||
pub mod entities; | ||
pub mod query_root; | ||
|
||
pub struct OrmDataloader { | ||
pub db: DatabaseConnection, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,21 @@ | ||
use crate::{entities::*, OrmDataloader}; | ||
use async_graphql::{dataloader::DataLoader, dynamic::*}; | ||
use crate::entities::*; | ||
use async_graphql::dynamic::*; | ||
use sea_orm::DatabaseConnection; | ||
use seaography::{Builder, BuilderContext}; | ||
use seaography::{async_graphql, lazy_static, Builder, BuilderContext}; | ||
|
||
lazy_static::lazy_static! { static ref CONTEXT : BuilderContext = BuilderContext :: default () ; } | ||
|
||
pub fn schema( | ||
database: DatabaseConnection, | ||
orm_dataloader: DataLoader<OrmDataloader>, | ||
depth: Option<usize>, | ||
complexity: Option<usize>, | ||
) -> Result<Schema, SchemaError> { | ||
let builder = Builder::new(&CONTEXT, database.clone()); | ||
let builder = crate::entities::register_entity_modules(builder); | ||
let schema = builder.schema_builder(); | ||
let schema = if let Some(depth) = depth { | ||
schema.limit_depth(depth) | ||
} else { | ||
schema | ||
}; | ||
let schema = if let Some(complexity) = complexity { | ||
schema.limit_complexity(complexity) | ||
} else { | ||
schema | ||
}; | ||
schema.data(database).data(orm_dataloader).finish() | ||
let mut builder = Builder::new(&CONTEXT, database.clone()); | ||
seaography::register_entities!(builder, [baker, bakery, cake, cake_baker,]); | ||
builder | ||
.set_depth_limit(depth) | ||
.set_complexity_limit(complexity) | ||
.schema_builder() | ||
.data(database) | ||
.finish() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters