Skip to content

Commit 2334e82

Browse files
committed
add max_rows to TableDirective
1 parent d40de1b commit 2334e82

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/sql_types.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,9 @@ pub struct TableDirectives {
482482
// @graphql({"primary_key_columns": ["id"]})
483483
pub primary_key_columns: Option<Vec<String>>,
484484

485+
// @graphql({"max_rows": 20})
486+
pub max_rows: Option<u64>,
487+
485488
/*
486489
@graphql(
487490
{
@@ -576,13 +579,22 @@ impl Table {
576579
pub fn is_any_column_selectable(&self) -> bool {
577580
self.columns.iter().any(|x| x.permissions.is_selectable)
578581
}
582+
579583
pub fn is_any_column_insertable(&self) -> bool {
580584
self.columns.iter().any(|x| x.permissions.is_insertable)
581585
}
582586

583587
pub fn is_any_column_updatable(&self) -> bool {
584588
self.columns.iter().any(|x| x.permissions.is_updatable)
585589
}
590+
591+
/// Get the effective max_rows value for this table.
592+
/// If table-specific max_rows is set, use that.
593+
/// Otherwise, fall back to schema-level max_rows.
594+
/// If neither is set, use the global default.
595+
pub fn max_rows(&self, schema: &Schema) -> u64 {
596+
self.directives.max_rows.unwrap_or(schema.directives.max_rows)
597+
}
586598
}
587599

588600
#[derive(Deserialize, Clone, Debug, Eq, PartialEq, Hash)]

0 commit comments

Comments
 (0)