(
database: DatabaseConnection,
depth: usize,
complexity: usize,
)
| 5 | lazy_static::lazy_static! { static ref CONTEXT: BuilderContext = BuilderContext::default(); } |
| 6 | |
| 7 | pub fn schema( |
| 8 | database: DatabaseConnection, |
| 9 | depth: usize, |
| 10 | complexity: usize, |
| 11 | ) -> Result<Schema, SchemaError> { |
| 12 | // Builder of Seaography query root |
| 13 | let builder = Builder::new(&CONTEXT, database.clone()); |
| 14 | // Register SeaORM entities |
| 15 | let builder = crate::models::_entities::register_entity_modules(builder); |
| 16 | // Configure async GraphQL limits |
| 17 | let schema = builder |
| 18 | .schema_builder() |
| 19 | // The depth is the number of nesting levels of the field |
| 20 | .limit_depth(depth) |
| 21 | // The complexity is the number of fields in the query |
| 22 | .limit_complexity(complexity); |
| 23 | // Finish up with including SeaORM database connection |
| 24 | schema.data(database).finish() |
| 25 | } |
no test coverage detected