#[cfg(feature = "async-graphql")]
use async_graphql::SchemaBuilder;
#[derive(Debug, Clone, Copy, Default)]
pub struct Limits {
pub max_depth: Option<usize>,
pub max_complexity: Option<usize>,
}
impl Limits {
pub fn new() -> Self {
Self::default()
}
pub fn max_depth(mut self, n: usize) -> Self {
self.max_depth = Some(n);
self
}
pub fn max_complexity(mut self, n: usize) -> Self {
self.max_complexity = Some(n);
self
}
#[cfg(feature = "async-graphql")]
pub fn apply<Q, M, S>(self, mut b: SchemaBuilder<Q, M, S>) -> SchemaBuilder<Q, M, S> {
if let Some(d) = self.max_depth {
b = b.limit_depth(d);
}
if let Some(c) = self.max_complexity {
b = b.limit_complexity(c);
}
b
}
}