refactor: consolidate duplicated name-matching and case helpers via inflekt@0.5.0#896
Merged
pyramation merged 11 commits intomainfrom Mar 26, 2026
Merged
Conversation
Reverts the PascalCase inflection applied in 6be9101. Relation target names in _meta (type, junctionTable.name, rightTable.name, referencedBy.name, references.name) now consistently use the raw PostGraphile codec name (e.g. post_tag, tag) rather than inflected GraphQL type names (PostTag, Tag). This keeps naming uniform across the entire _meta schema and ensures the dashboard phantom-column junction filter can directly compare junctionTable.name from manyToMany entries against referencedBy.name from hasMany entries without any case normalisation.
…b-path resolution" This reverts commit e802f9b.
Extract duplicated fuzzy table-name matching logic from field-selector.ts and select.ts into a shared name-matching.ts module. Both files now import fuzzyFindByName from the shared utility instead of duplicating the normalize + compare logic inline. Also adds NOTE comments to codegen/utils.ts indicating that lcFirst, ucFirst, toCamelCase, toPascalCase, and toScreamingSnake can be replaced with re-exports from inflekt once version 0.4.0 is published (see dev-utils PR #71).
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:
|
- Bump inflekt to ^0.5.0 in graphql/query, graphql/codegen, graphile/graphile-settings - Import fuzzyFindByName directly from inflekt in field-selector.ts and select.ts - Delete local name-matching.ts (no longer needed) - Replace local lcFirst/ucFirst/toCamelCase/toPascalCase/toScreamingSnake in codegen/utils.ts with re-exports from inflekt (single source of truth)
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
Bumps
inflektto^0.5.0acrossgraphql/query,graphql/codegen, andgraphile/graphile-settings, then replaces duplicated logic with direct imports from the published package:field-selector.ts/select.ts: ImportfuzzyFindByNamefrominflektinstead of duplicating normalize + compare inline. The intermediate localname-matching.tsmodule (added in an earlier revision) has been deleted — inflekt is now the single source of truth.codegen/utils.ts: Replaces locallcFirst,ucFirst,toCamelCase,toPascalCase,toScreamingSnakefunction bodies with re-exports frominflekt.relation-meta-builders.ts: Minor cleanup — extracts repeatedrelation.remoteResource?.codecinto a localremoteCodecvariable.Companion PR: constructive-io/dev-utils#71 (adds these utilities to inflekt).
This is not a pure refactor. Two behavioral changes are included:
select.ts→findRelatedTable: Previously did exact match only. Now uses fuzzy matching (case-insensitive, underscore-stripping, trailing-'s' tolerance). This means relation lookups that previously returnednullmay now resolve correctly when codec names differ in case/pluralization from table type names.field-selector.ts→getRelatedTableScalarFields: When no related table is found, the fallback changed fromreturn {}toreturn { __typename: true }so generated queries remain valid (connection nodes require at least one subfield).Updates since last revision
maininto the branch to fix a CI lockfile failure (ERR_PNPM_LOCKFILE_MISSING_DEPENDENCYforinflekt@0.3.3). The lockfile now includes bothinflekt@0.3.3(transitive, from other packages on main) andinflekt@0.5.0.Review & Testing Checklist for Human
select.tsdoesn't produce false-positive table matches. The newfindRelatedTablenow fuzzy-matches where it previously only did exact match. If two tables have names that normalize to the same base (e.g., hypothetical"Status"vs"Statuses"table), this could match the wrong one. Scan your schema for any ambiguous table names.{ __typename: true }fallback infield-selector.tsline ~307. Previously returned{}when the related table wasn't found. Confirm that__typenameis acceptable as a minimum subfield selection for connection nodes in your PostGraphile setup.codegen/utils.tspreviously definedtoCamelCase,toPascalCase,toScreamingSnakelocally. These are now re-exported from inflekt. Verify the inflekt implementations match expected behavior (especially edge cases like leading underscores, consecutive capitals, etc.).Notes
pnpm-lock.yamldiff is large due to lockfile format changes and a merge with main; the only meaningful dependency change isinflekt 0.3.3 → 0.5.0. The lockfile retains ainflekt@0.3.3snapshot because it is still transitively reachable from main.fuzzyFindByNamesingularizes the target name but not the item names. Looking up"shipments"will find"Shipment", but"Shipment"will not find"Shipments". Verify this matches the actual direction of lookups (codec name → table type name).Link to Devin session: https://app.devin.ai/sessions/e3dd5ed7753043bd8d2166793364cd42
Requested by: @pyramation