Skip to content

Commit f23b1af

Browse files
committed
Register "related entity" / "entity" without relation
1 parent 28b7930 commit f23b1af

File tree

4 files changed

+25
-19
lines changed

4 files changed

+25
-19
lines changed

examples/sqlite/src/query_root.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ pub fn schema(
1111
depth: Option<usize>,
1212
complexity: Option<usize>,
1313
) -> Result<Schema, SchemaError> {
14-
let builder = seaography::register_entities!(
14+
let builder = seaography::register_related_entities!(
1515
Builder::new(&CONTEXT),
1616
&CONTEXT,
1717
[

generator/src/writer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ pub fn generate_query_root<P: AsRef<Path>>(entities_path: &P) -> TokenStream {
9696
depth: Option<usize>,
9797
complexity: Option<usize>,
9898
) -> Result<Schema, SchemaError> {
99-
let builder = seaography::register_entities!(Builder::new(&CONTEXT), &CONTEXT, [
99+
let builder = seaography::register_related_entities!(Builder::new(&CONTEXT), &CONTEXT, [
100100
#(#entities,)*
101101
]);
102102

src/builder.rs

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -244,27 +244,33 @@ pub trait RelationBuilder {
244244
}
245245

246246
#[macro_export]
247-
macro_rules! register_entity {
248-
($builder:expr, $context:expr, $module_path:ident) => {{
249-
use sea_orm::Iterable;
250-
247+
macro_rules! register_related_entity {
248+
($builder:expr, $module_path:ident) => {
251249
$builder.register_entity::<$module_path::Entity>(
252-
$module_path::RelatedEntity::iter()
253-
.map(|rel| seaography::RelationBuilder::get_relation(&rel, $context))
250+
<$module_path::RelatedEntity as sea_orm::Iterable>::iter()
251+
.map(|rel| seaography::RelationBuilder::get_relation(&rel, $builder.context))
254252
.collect(),
255253
);
256-
}};
254+
};
257255
}
258256

259257
#[macro_export]
260-
macro_rules! register_entities {
261-
($builder:expr, $context:expr, [$($module_paths:ident),+ $(,)?]) => {{
262-
{
263-
let mut builder = $builder;
258+
macro_rules! register_related_entities {
259+
($builder:expr, [$($module_paths:ident),+ $(,)?]) => {
260+
$(seaography::register_related_entity!($builder, $module_paths);)*
261+
};
262+
}
264263

265-
$(seaography::register_entity!(builder, $context, $module_paths);)*
264+
#[macro_export]
265+
macro_rules! register_entity {
266+
($builder:expr, $module_path:ident) => {
267+
$builder.register_entity::<$module_path::Entity>(vec![]);
268+
};
269+
}
266270

267-
builder
268-
}
269-
}};
271+
#[macro_export]
272+
macro_rules! register_entities {
273+
($builder:expr, [$($module_paths:ident),+ $(,)?]) => {
274+
$(seaography::register_entity!($builder, $module_paths);)*
275+
};
270276
}

src/inputs/active_enum_filter_input.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use async_graphql::dynamic::{InputObject, InputValue, ObjectAccessor, TypeRef};
22
use heck::ToUpperCamelCase;
3-
use sea_orm::{ActiveEnum, ColumnTrait, Condition, DynIden, Iden};
3+
use sea_orm::{ActiveEnum, ColumnTrait, Condition, DynIden, Iden, sea_query::SeaRc};
44

55
use crate::{ActiveEnumBuilder, BuilderContext};
66

@@ -68,7 +68,7 @@ impl ActiveEnumFilterInputBuilder {
6868
pub fn prepare_enumeration_condition<T>(
6969
filter: &ObjectAccessor,
7070
column: T,
71-
variants: &[std::sync::Arc<dyn Iden>],
71+
variants: &[SeaRc<dyn Iden>],
7272
condition: Condition,
7373
) -> Condition
7474
where

0 commit comments

Comments
 (0)