feat: add scoped introspection aligned with Crystal #2 - #1823
Conversation
|
Review complete. 🟡 1 medium 💬 Inline comments (1)
This PR introduces
Note: the high-recall sweep pass did not publish output (hit its step cap), so coverage relies on the lens, domain, and holistic passes; the verifier adjudicated 7 candidates (4 rejected, 2 merged). Reviewed commit: 66c6bf8 |
There was a problem hiding this comment.
Adds a schema-scoped PostGraphile introspection plugin with a new graphile-scoped-introspection package, server middleware for lazy preset loading, type exports, and a perf-harness benchmark suite.
Key findings
- 🟡 Align version sentinel with peer range — plugin.ts:64
Small GraphQL APIs currently pay catalog introspection costs for unrelated schemas in the same PostgreSQL database. Add an opt-in, CNC-owned replacement plugin that follows service schemas and their dependency closure.
Supersedes #1719 and follows the configuration and query behavior in Crystal #2 (
441cef73b0a12ed24343b7f38241af28b6454280).Behavior
graphile-scoped-introspection; no upstream patches or upgrades.gather.pgScopedIntrospection: omitted/false uses stock,trueuses scoped defaults (catalogTypes: all), and an options object supports explicit catalog policy and capability extensions.graphile.preset/graphile.extends, loads the replacement lazily, preservesintrospectionRole, and coalesces handler creation before async preset work.graphile-build-pg@5.1.3; stock without scoped configuration does not load that contract guard.CNC configuration:
Temporary copies and upstream migration
The copied scoped SQL, validation logic, and adapted introspection helper code are a temporary compatibility bridge for CNC's currently pinned Graphile dependencies. The intent is to consume the Crystal implementation upstream, rather than maintain a permanent CNC fork.
Once this functionality is merged into upstream Crystal and available in a compatible published release, upgrade CNC's dependencies and replace the local copies/replacement plugin with the upstream implementation. Retain only CNC-specific configuration wiring that is still needed, preserve the per-service configuration semantics where supported, and rerun the schema/runtime equivalence and default-performance checks before removing the bridge. If upstream changes the configuration contract, handle that migration explicitly.
Validation
Default performance
Stock versus
main: trueonly; target fixed at 9 tables / 8 functions. Values are medians on a shared host.At 50 unrelated schemas, retained heap drops from 103.2 to 26.5 MiB. The default scoped query is slower in smaller catalogs, so the result is workload-dependent and is not a universal speedup or a production latency claim.
The PR includes methodology and results, a reproducible runner, environment metadata, and individual samples.