fix(inflection): use inflekt package for PostGraphile-compatible pluralization #567
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
Fixes incorrect pluralization of 'regimen' that caused naming conflicts in GraphQL schema generation when both 'regimen' and 'regimens' tables existed.
Problem:
singularize('regimen')returned 'regiman' instead of 'regimen'pluralize('regimen')returned 'regimen' (no change)Solution:
inflekt@0.1.0package for pluralize/singularize operationsinflektlibrary correctly handles 'regimen' → 'regimens' and other edge cases including Latin suffix overrides (schemata → schema, criteria → criterion, etc.)graphile-simple-inflectorandgraphql-codegenpackages to useinflektChanges:
inflektpackage as a dependency to graphile-simple-inflector and graphql-codegeninflectionpackage dependency from both packagespluralize.tswrapper file in codegen - all files now import directly frominflektUpdates since last revision
inflectionpackage with newly publishedinflekt@0.1.0in both graphile-simple-inflector and graphql-codegenpluralize.tswrapper file entirely - all imports now come directly frominflektsingularize/pluralizefrominflektfor module API compatibilityReview & Testing Checklist for Human
inflekt@0.1.0exports all required functions (camelize, singularize, pluralize, underscore, lcFirst, ucFirst, toFieldName, toQueryName) - this is a newly published packageUserRegimensOrderBy,RegimenCondition)cd graphile/graphile-simple-inflector && pnpm testRecommended test plan: Create test tables with singular and plural names (regimen, regimens, user_regimen) and verify PostGraphile generates non-conflicting, correctly-named GraphQL types. Also test codegen output to ensure generated TypeScript uses correct pluralization.
Notes
This PR uses the newly published
inflekt@0.1.0package which wraps theinflectionnpm package with PostGraphile-compatible Latin suffix overrides. Since inflekt is a new package (v0.1.0), extra verification is recommended.Link to Devin run: https://app.devin.ai/sessions/0a2a8e7889894852863ad967c5e79636
Requested by: Dan Lynch (@pyramation)