Open
Conversation
When using the CLI (cnc codegen or graphql-codegen) with a config file
that has db.pgpm, the buildGenerateOptions function was dropping the
pgpm config during the flatten/rebuild cycle:
1. seedArgvFromConfig flattens db to extract schemas/apiNames
2. buildGenerateOptions rebuilds db with only schemas/apiNames
3. The spread { ...fileConfig, ...withDb } overwrites fileConfig.db
This caused pgpm-based configs to silently fall back to database mode,
ignoring the pgpm module path and potentially connecting to the wrong
database.
Fix:
- Deep-merge db configs in buildGenerateOptions to preserve pgpm,
config, keepDb, and other db fields from the file config
- Apply same fix to multi-target CLI path in cli/index.ts
- Filter undefined values in buildDbConfig to prevent overwriting
file config values with undefined CLI defaults
Add functionResourceName override to InflektPlugin to restore schema prefixes for functions while keeping clean names for tables. Filter ConflictDetectorPlugin by configured schemas to prevent false positives.
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
Attempted to add a second resource named "table_grant") when a function and a table share the same base name across schemas.functionResourceNameoverride toInflektPluginthat restores schema prefixes for functions while keeping clean, unprefixed names for tables.ConflictDetectorPluginby configuredpgServices.schemasto prevent false-positive warnings from unrelated schemas.Problem
InflektPlugin._schemaPrefixcurrently returns''for all schemas to give tables clean GraphQL names. However,PostGraphile’sfunctionResourceNamealso uses_schemaPrefix, which means functions lose their schema prefix too.When a function and a table share the same base name across schemas (e.g.
actions_public.table_grant()andmetaschema_public.table_grant), both end up with the resource nametable_grant, and PostGraphile’s flat registry throws.Solution
Override
functionResourceNameinInflektPluginto bypass our_schemaPrefixoverride and use PostGraphile’s default prefix logic for functions only:metaschema_public.table_grant(table)schemas[0])table_grantTableGrantactions_public.table_grant()(function)actions_public_table_grantactionsPublicTableGrantFunctions in the primary schema still get clean names (no prefix). Functions in non-primary schemas get their schema name as a prefix, preventing collisions with same-named tables.
Test plan
graphile-settingsbuilds successfullygraphql/codegen— 230 tests pass, 75 snapshots matchconstructive-db/sdk/constructive-sdk—pnpm run generatecompletes (72 tables, 82 queries, 314 mutations)constructive-db/application/app— 101 tests pass (4 test suites have pre-existing TS type errors unrelated to this change)