Add postgres configuration store for on-demand schema loading#179
Open
Add postgres configuration store for on-demand schema loading#179
Conversation
Adds an alternate configuration mode where the connector reads collection schemas from a PostgreSQL config store (config_tables.raw_schema) instead of filesystem JSON files. Configuration is fetched per-request rather than cached at startup, enabling dynamic schema management. Key changes: - New `configuration-store` crate with ConfigurationMode resolver and PostgresConfigurationStore backed by deadpool-postgres connection pool - ConnectorConfig enum (Static/Postgres) replaces MongoConfiguration as the SDK Configuration type - Per-query: fetches only the requested collection's schema from postgres - get_schema returns empty in postgres mode (schema managed externally) - Mutations unsupported in postgres mode (native mutations not stored) - TLS support via native-tls for postgres connections with sslmode - Connection URI read from config_metadata or MONGODB_DATABASE_URI env var Env vars: - HASURA_CONFIGURATION_MODE: "json" (default) or postgres URL - HASURA_CONFIGURATION_CONNECTOR_ID: required for postgres mode - HASURA_CONFIGURATION_SCHEMA: postgres schema name (default: connector_config) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
getrandom 0.3.4 (via rand_core 0.9.5) pulls in wit-bindgen 0.51.0 which requires edition2024, stabilized in Rust 1.85.0. This fixes the Nix build failure in CI. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The cargo-audit step fails because the RustSec advisory database now includes advisories with CVSS 4.0 scores, which older cargo-audit versions cannot parse. Updating nixpkgs brings in a newer cargo-audit that supports CVSS 4.0. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
91aa883 to
d768914
Compare
- Add read_collections_configuration() to fetch and merge schemas for multiple collections in a single request. Previously only the primary collection's schema was loaded, causing "Unknown collection" errors when queries referenced related collections (e.g. Album -> Track). - Extract all collection names from QueryRequest (primary + relationship targets) before resolving configuration. - Fix config_tables query to use is_deleted = false instead of deleted_at IS NULL to match the actual table schema. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
d768914 to
0a58c2b
Compare
tokio-postgres 0.7.13+ pulls in rand 0.9 → getrandom 0.3 → wasip2 → wit-bindgen 0.51.0 which requires Rust edition 2024 (Cargo 1.85+). Our Nix build uses Rust 1.83.0, so pin to <0.7.13 to keep CI working. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
config_tables.raw_schema) instead of filesystem JSON filesconfiguration-storecrate withConfigurationModeresolver andPostgresConfigurationStorebacked bydeadpool-postgresconnection poolnative-tlsfor postgres connections (?sslmode=requirein URL)Debugimpls (postgres URL redacted in logs)wit-bindgen 0.51.0requires edition2024)cargo-auditfailure parsing CVSS 4.0 scores in newer RustSec advisoriesEnv vars
HASURA_CONFIGURATION_MODEjson(default) or a postgres connection URLHASURA_CONFIGURATION_CONNECTOR_IDHASURA_CONFIGURATION_SCHEMAconnector_config)Behavior in postgres mode
/query: fetches schemas for all collections referenced in the request (primary + relationship targets) fromconfig_tables.raw_schema, merges them into a single configuration/schema: returns empty response (schema managed externally)/mutation: returns 501 Not Implemented (native mutations not in postgres store)config_metadatatable, falls back toMONGODB_DATABASE_URIenv varChanges in this update
Album→Track→Genre) now work correctly. The connector extracts all collection names from theQueryRequest(primary collection + allcollection_relationshipstargets) and fetches/merges their schemas from the config store.config_tablesquery usesis_deleted = falseinstead ofdeleted_at IS NULLto match the actual table schema.Test plan
🤖 Generated with Claude Code