Skip to content

Commit

Permalink
Update seaography examples
Browse files Browse the repository at this point in the history
  • Loading branch information
billy1624 committed Dec 2, 2024
1 parent 903d5c4 commit 1b7ca1a
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 13 deletions.
6 changes: 1 addition & 5 deletions examples/loco_seaography/src/graphql/query_root.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,7 @@ pub fn schema(
// Builder of Seaography query root
let mut builder = Builder::new(&CONTEXT, database.clone());
// Register SeaORM entities
seaography::register_entities!(
builder,
// List all models we want to include in the GraphQL endpoint here
[files, notes, users]
);
let builder = crate::models::_entities::register_entity_modules(builder);
// Configure async GraphQL limits
let schema = builder
.schema_builder()
Expand Down
6 changes: 6 additions & 0 deletions examples/loco_seaography/src/models/_entities/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,9 @@ pub mod prelude;
pub mod files;
pub mod notes;
pub mod users;

seaography::register_entity_modules!([
files,
notes,
users,
]);
8 changes: 2 additions & 6 deletions examples/react_admin/backend/src/graphql/query_root.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,9 @@ pub fn schema(
complexity: usize,
) -> Result<Schema, SchemaError> {
// Builder of Seaography query root
let mut builder = Builder::new(&CONTEXT, database.clone());
let builder = Builder::new(&CONTEXT, database.clone());
// Register SeaORM entities
seaography::register_entities!(
builder,
// List all models we want to include in the GraphQL endpoint here
[files, notes, users]
);
let builder = crate::models::_entities::register_entity_modules(builder);
// Configure async GraphQL limits
let schema = builder
.schema_builder()
Expand Down
6 changes: 6 additions & 0 deletions examples/react_admin/backend/src/models/_entities/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,9 @@ pub mod prelude;
pub mod files;
pub mod notes;
pub mod users;

seaography::register_entity_modules!([
files,
notes,
users,
]);
7 changes: 7 additions & 0 deletions examples/seaography_example/graphql/src/entities/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,10 @@ pub mod baker;
pub mod bakery;
pub mod cake;
pub mod cake_baker;

seaography::register_entity_modules!([
baker,
bakery,
cake,
cake_baker,
]);
4 changes: 2 additions & 2 deletions examples/seaography_example/graphql/src/query_root.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ pub fn schema(
depth: Option<usize>,
complexity: Option<usize>,
) -> Result<Schema, SchemaError> {
let mut builder = Builder::new(&CONTEXT, database.clone());
seaography::register_entities!(builder, [baker, bakery, cake, cake_baker,]);
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)
Expand Down

0 comments on commit 1b7ca1a

Please sign in to comment.