feat: typed table reads for CORS, pubkey, webauthn, database_settings + Graphile feature flag wiring#1091
Merged
pyramation merged 1 commit intomainfrom May 10, 2026
Merged
Conversation
… + Graphile feature flag wiring Phase 3 (continued) + Phase 4 of the unified settings architecture: - Add DatabaseSettings, PubkeyChallengeSettings, WebauthnSettings interfaces to types.ts - Add corsOrigins, databaseSettings, pubkeyChallengeSettings, webauthnSettings to ApiStructure - Implement SQL queries for cors_settings, pubkey_settings, webauthn_settings, database_settings with LEFT JOINs to metaschema_public.schema and metaschema_public.function - Add try/catch fallback pattern: typed table first, then legacy api_modules - Update cors.ts to read from api.corsOrigins (typed table) with api_modules fallback - Wire database_settings feature flags into Graphile preset (enable_aggregates adds PgAggregatesPreset) - Re-export PgAggregatesPreset from graphile-settings for server consumption - All new queries run in parallel via Promise.all in both resolveApiNameHeader and resolveDomainLookup
Contributor
🤖 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:
|
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
Continues the unified settings architecture (Phases 3–4, per constructive-planning#812). Builds on the RLS pattern from PR #1086 to read from all remaining typed settings tables with backwards-compatible fallback to
api_modules.Server-side reads (Phase 3 continued):
cors_settings(per-API, then db-default), falls back toapi_moduleslegacycorsmodulepubkey_settings(with LEFT JOINs tometaschema_public.schema/function), falls back toapi_moduleslegacypubkey_challengemodulewebauthn_settings(with LEFT JOINs to 4 schema FKs), no legacy fallback neededdatabase_settingswithapi_settingscascade viaCOALESCEAll queries use the same try/catch →
undefinedfallback pattern so deployments without the new tables continue working.Graphile feature flag wiring (Phase 4):
buildPreset()now acceptsdatabaseSettingsand conditionally includesPgAggregatesPresetwhenenableAggregatesis trueApiStructurebut do not yet disable their corresponding plugins — deferred to a follow-up that maps each flag to specificdisablePluginsentriesOther changes:
toApiStructurefrom positional args to aResolvedSettingsobjectresolveApiNameHeaderandresolveDomainLookupnow run all 6 settings queries in parallel viaPromise.allcors.tsreadsapi.corsOrigins(typed) and merges with legacyapi_modulesCORS dataPgAggregatesPresetfromgraphile-settingsso the server doesn't need a direct dependencyReview & Testing Checklist for Human
PUBKEY_SETTINGS_SQL,WEBAUTHN_SETTINGS_SQL,DATABASE_SETTINGS_SQL, andCORS_SETTINGS_SQLmatch the table definitions from constructive-db PRs feat(node-type-registry): add DataLimitCounter, DataFeatureFlag, AuthzAppMembership #1060/fix(presigned-url): match files→buckets by table name prefix instead of schema name #1075. Mismatches would be silently swallowed by the try/catch.queryCorsSettingsintroduces a db-default cascade (api_id IS NULL) thatqueryCorsModuleLegacydoes not have. Confirm this is desired new behavior, not an unintentional divergence.queryCorsModuleLegacylacks try/catch — Unlike all other legacy fallback functions, the CORS legacy query will throw on DB errors rather than returningundefined. Verify this is acceptable or should be wrapped.enableAggregatesactually gates a plugin. The other 8 flags are carried onApiStructurebut don't disable anything yet. Confirm this partial wiring is acceptable for now.pgpm deploy— Test against a real database to verify the typed table queries return correct data and theapi_modulesfallback works when typed tables are empty.Notes
ConstructivePreset,makePgService,streamToStoragenot found) are confirmed present on main — they require buildinggraphile-settingsfirst.svcCacheLRU cache (1-year TTL) means the additional queries only fire on cold starts / cache misses.Link to Devin session: https://app.devin.ai/sessions/94a2728a9c414500bead29cbbc829c15
Requested by: @pyramation