feat: refactor ConstructivePreset into createConstructivePreset() factory with feature flag options#1092
Merged
pyramation merged 1 commit intomainfrom May 10, 2026
Merged
Conversation
…tory Convert static ConstructivePreset into a factory function that accepts ConstructivePresetOptions (mirrors database_settings/api_settings flags). Each feature flag controls whether its corresponding plugin preset is included in the generated Graphile config: enableConnectionFilter -> ConnectionFilterPreset, EnableAllFilterColumnsPreset enableManyToMany -> ManyToManyOptInPreset enableSearch -> UnifiedSearchPreset enablePostgis -> GraphilePostgisPreset enableLtree -> GraphileLtreePreset enableDirectUploads -> UploadPreset enablePresignedUploads -> PresignedUrlPreset, BucketProvisionerPreset enableAggregates -> PgAggregatesPreset enableLlm -> reserved (no plugin yet) connectionFilterOperatorFactories are dynamically built based on which satellite plugins (search, postgis, ltree) are enabled. The static ConstructivePreset export is preserved for backwards compat as createConstructivePreset() with no args (all defaults). Server's buildPreset() now passes databaseSettings directly to the factory, wiring the full feature flag cascade end-to-end.
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
Converts the static
ConstructivePresetobject into acreateConstructivePreset(options?)factory function. Each optional boolean flag inConstructivePresetOptionsmaps 1-to-1 with thedatabase_settings/api_settingstables (from constructive-db#1060), controlling whether its corresponding Graphile plugin preset is included in the generated config.Key changes:
ConstructivePresetOptionsinterface with 9 flags:enableAggregates,enablePostgis,enableSearch,enableDirectUploads,enablePresignedUploads,enableManyToMany,enableConnectionFilter,enableLtree,enableLlmextendsarray,connectionFilterOperatorFactories,disablePlugins, andschemaoptions based on which flags are enabledbuildPreset()now passesdatabaseSettingsdirectly tocreateConstructivePreset()— all flags flow through, replacing the previous approach where onlyenableAggregateswas handled manuallyexport const ConstructivePreset = createConstructivePreset()preserves the static import for existing consumers (defaults match previous behavior: everything on except aggregates and LLM)This completes the end-to-end feature flag wiring:
database_settingsrow → server reads →createConstructivePreset(settings)→ each plugin conditionally included/excluded.Review & Testing Checklist for Human
DatabaseSettingsproperty names matchConstructivePresetOptions— the factory receivesdatabaseSettingsdirectly asoptionsvia spread ({ ...DEFAULTS, ...options }). If any property name differs (e.g.,enableDirectUploadsvsenable_direct_uploads), that flag silently falls back to the default. Checkgraphql/server/src/types.tsto confirm alignment.operatorFactoriesgating logic is correct — operator factories are only built whenenableConnectionFilteristrueAND the satellite feature (search/postgis/ltree) is also enabled. Previously these were always included. If connection filter is disabled, no operator factories ordisablePluginsare set — confirm the app works correctly with PgConditionArgumentPlugin still active in that case.createBucketNameResolver(),createEnsureBucketProvisioned(),getAllowedOrigins(),getPresignedUrlS3Configare now called per-createConstructivePreset()invocation (once per tenant) rather than once at module load. Verify these are safe to call multiple times / return fresh-but-equivalent results.enable_aggregates = trueindatabase_settingsactually exposes aggregates in the GraphQL schema, (3) setting a feature tofalseactually removes its types/fields from the schema.Notes
enableLlmis reserved/no-op (no plugin exists yet).operatorFactoriesis typed asunknown[]— matches the existing pattern but is worth tightening in a follow-up.Link to Devin session: https://app.devin.ai/sessions/94a2728a9c414500bead29cbbc829c15
Requested by: @pyramation