fix(graphql-server): bound introspection depth with its own fixed ceiling - #1818
Conversation
…ling
The introspection subtree was skipped entirely by the gate, so a recursive
__schema { types { fields { type { fields ... } } } } document could nest
without limit. Walk it again, but against INTROSPECTION_MAX_DEPTH (16) rather
than the tenant's maxQueryDepth, so the standard introspection document (13)
still passes while runaway recursion is rejected.
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
|
Review complete. No issues found — approved ✅. This change hardens the document gate's handling of schema introspection in
Reviewed commit: 8d20e5c |
Summary
Follow-up to #1817, addressing the review finding at https://github.com/constructive-io/constructive/pull/1817/changes#r3962532563.
#1817 skipped the
__schema/__typesubtree entirely, but the introspection schema is recursive (__Type.fields → __Field.type → __Type), so{ __schema { types { fields { type { fields { type … } } } } } }could nest without limit and still report{ depth: 1, cost: 0 }.The gate now walks the introspection subtree again, but measures it against a fixed
INTROSPECTION_MAX_DEPTH = 16(relative to the introspection field) instead of the tenant'smaxQueryDepth:The standard introspection document (graphql-js
getIntrospectionQuerywith all options) is 13 deep, so codegen/tooling still passes under any tenant depth budget, while runaway recursive introspection is rejected. Introspection depth is not reported inanalysis.depthand cost stays 0 (no connections in introspection types). Tests cover the recursive shape being rejected at 9 hops and accepted at 6.Link to Devin session: https://app.devin.ai/sessions/1c0e1e05988944c2995bd82bb7e0c215
Open in Devin Desktop: https://app.devin.ai/desktop/session/1c0e1e05988944c2995bd82bb7e0c215?variant=devin
Requested by: @pyramation