Expand description
Minimal GraphQL lexer (Phase 11) — the 8th custom parser in this crate (fuzzed,
see ARCHITECTURE §13). It does NOT build an AST: it makes a single linear,
UTF-8-safe, allocation-free pass over the query text and computes the structural
metrics the graphql detection module enforces (depth / aliases / fields /
directives / introspection). It is evasion-robust at the LEXICAL level — braces,
colons and names inside strings, block strings ("""…""") and # comments are
skipped, so they cannot inflate or deflate the counts.
Paren-aware depth. { } delimits a selection set (which is what “depth”
means for a GraphQL DoS) but ALSO an input object inside an argument list
(field(arg: { … })). To count only selection-set nesting, a { increments the
depth ONLY while not inside ( … ). So a query with a deeply nested input
object but a flat selection set reports a small depth (no false positive).
Structs§
- Graphql
Stats - Structural metrics of one GraphQL query/operation text.
Functions§
- graphql_
lex - Lex
sand compute itsGraphqlStats. Linear time, no allocation, never panics. - unwrap_
query_ envelope - If
sis a JSON envelope carrying GraphQL operation text(s) — a{"query":"<doc>"}object or a[{"query":…}, …]batch array — return those operation strings;Nonewhensis a bare GraphQL document or not such an envelope (the caller then lexessdirectly).