pub struct RouteGraphql {
pub enabled: bool,
pub depth_limit: usize,
pub complexity_limit: u64,
pub complexity_coefficient: u64,
pub cost_per_field: HashMap<String, u64>,
pub persisted_queries: Option<GraphqlPersistedQueries>,
pub federation: Option<GraphqlFederation>,
}Expand description
Route-scoped GraphQL awareness config (DW-099, routes[].graphql).
When enabled (compiled into every build; no cargo feature), the
gateway enforces query depth/complexity limits and optional
persisted-query enforcement on every request the route matches,
BEFORE the route limits and authentication. A query whose depth or
complexity exceeds the configured limits is rejected with 400
(graphql_depth_exceeded or graphql_complexity_exceeded); a
query whose SHA-256 hash is not in the persisted-query store is
rejected with 400 (graphql_persisted_query_required).
The check is compiled into every build (no cargo feature): a config carrying the block behaves identically in any build.
Depth is the maximum brace-nesting level of the query (the
top-level operation body is depth 1). Complexity is the sum of
per-field costs: each field’s cost is looked up in
cost_per_field, falling back to complexity_coefficient (default
- when the field name is not in the map.
Both are computed by a bounded hand-rolled scanner (no external GraphQL parser dependency).
Fields§
§enabled: boolMaster switch. Default false: the GraphQL block is inert even when present (allows staged rollout). When true, the depth and complexity checks run on every request the route matches.
depth_limit: usizeMaximum query depth (max brace-nesting level). A query whose
depth exceeds this is rejected with 400
graphql_depth_exceeded. Must be > 0 when the block is
enabled (validation rejects 0 or absent). The top-level
operation body is depth 1, so a value of 1 permits only a
flat selection set with no nested fields.
complexity_limit: u64Maximum query complexity (sum of per-field costs). A query
whose complexity exceeds this is rejected with 400
graphql_complexity_exceeded. Must be > 0 when the block is
enabled.
complexity_coefficient: u64Default cost per field when the field name is not in
cost_per_field (default 1). The complexity total is
sum(cost_per_field[name].unwrap_or(complexity_coefficient)).
cost_per_field: HashMap<String, u64>Per-field cost overrides. Maps a field name to its explicit
cost; any field not in this map uses
complexity_coefficient. Empty (the default): every field
costs complexity_coefficient.
persisted_queries: Option<GraphqlPersistedQueries>Persisted-query enforcement (Apollo APQ + GET-by-hash variant).
When enabled, every request’s query SHA-256 hash must be in the
configured store (a map of hash -> query text). A hash not in
the store is rejected with 400
graphql_persisted_query_required. Absent (the default): no
persisted-query enforcement.
federation: Option<GraphqlFederation>Federation passthrough config (DP-11, #256). When enabled, the
gateway treats the route as a federation passthrough: it
forwards GraphQL requests to a single federated upstream
(subgraph or supergraph router) while preserving
federation-specific headers and allowing introspection queries
(_service, __schema) to bypass depth/complexity checks.
Trait Implementations§
Source§impl Clone for RouteGraphql
impl Clone for RouteGraphql
Source§fn clone(&self) -> RouteGraphql
fn clone(&self) -> RouteGraphql
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for RouteGraphql
impl Debug for RouteGraphql
Source§impl<'de> Deserialize<'de> for RouteGraphql
impl<'de> Deserialize<'de> for RouteGraphql
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl JsonSchema for RouteGraphql
impl JsonSchema for RouteGraphql
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
$ref keyword. Read moreSource§impl PartialEq for RouteGraphql
impl PartialEq for RouteGraphql
Source§impl Serialize for RouteGraphql
impl Serialize for RouteGraphql
impl StructuralPartialEq for RouteGraphql
Auto Trait Implementations§
impl Freeze for RouteGraphql
impl RefUnwindSafe for RouteGraphql
impl Send for RouteGraphql
impl Sync for RouteGraphql
impl Unpin for RouteGraphql
impl UnwindSafe for RouteGraphql
Blanket Implementations§
§impl<T> AnyExt for T
impl<T> AnyExt for T
§fn downcast_ref<T>(this: &Self) -> Option<&T>where
T: Any,
fn downcast_ref<T>(this: &Self) -> Option<&T>where
T: Any,
T behind reference§fn downcast_mut<T>(this: &mut Self) -> Option<&mut T>where
T: Any,
fn downcast_mut<T>(this: &mut Self) -> Option<&mut T>where
T: Any,
T behind mutable reference§fn downcast_rc<T>(this: Rc<Self>) -> Result<Rc<T>, Rc<Self>>where
T: Any,
fn downcast_rc<T>(this: Rc<Self>) -> Result<Rc<T>, Rc<Self>>where
T: Any,
T behind Rc pointer§fn downcast_arc<T>(this: Arc<Self>) -> Result<Arc<T>, Arc<Self>>where
T: Any,
fn downcast_arc<T>(this: Arc<Self>) -> Result<Arc<T>, Arc<Self>>where
T: Any,
T behind Arc pointer§fn downcast_box<T>(this: Box<Self>) -> Result<Box<T>, Box<Self>>where
T: Any,
fn downcast_box<T>(this: Box<Self>) -> Result<Box<T>, Box<Self>>where
T: Any,
T behind Box pointer§fn downcast_move<T>(this: Self) -> Option<T>
fn downcast_move<T>(this: Self) -> Option<T>
Self to T,
useful only in generic context as a workaround for specializationSource§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T, X> CoerceTo<T> for Xwhere
T: CoerceFrom<X> + ?Sized,
impl<T, X> CoerceTo<T> for Xwhere
T: CoerceFrom<X> + ?Sized,
fn coerce_rc_to(self: Rc<X>) -> Rc<T>
fn coerce_box_to(self: Box<X>) -> Box<T>
fn coerce_ref_to(&self) -> &T
fn coerce_mut_to(&mut self) -> &mut T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more