feat: add @interweb/inflection library for PostGraphile-compatible pluralization#56
Merged
pyramation merged 2 commits intomainfrom Jan 7, 2026
Merged
Conversation
🤖 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
Adds a new
@interweb/inflectionpackage that provides pluralization and singularization utilities with PostGraphile-compatible Latin suffix handling. This library is intended to be shared betweengraphile-simple-inflectorand@constructive-io/graphql-codegento ensure consistent inflection behavior across the codebase.The library includes:
singularize/pluralizewith Latin suffix overrides in both directions (schemata↔schema, criteria↔criterion, etc.)singularizeLast/pluralizeLastfor compound word handling (only transforms the last word)distinctPluralizefor cases where singular equals plurallcFirst,ucFirst,fixCapitalisedPlural)toFieldName,toQueryName)Updates since last revision
Added
LATIN_PLURAL_OVERRIDESto thepluralizefunction so that Latin-style plurals are used (e.g.,schema→schemata,criterion→criteria). This maintains backward compatibility with PostGraphile's expected GraphQL field names. Without this fix, upgrading would cause breaking changes where fields likeschematawould becomeschemas.Review & Testing Checklist for Human
LATIN_PLURAL_OVERRIDESlist matchesLATIN_SUFFIX_OVERRIDES(they should be inverses of each other)pluralize('schema')returns'schemata'andpluralize('Schema')returns'Schemata'(case preservation)changeLastWordregex pattern inpluralize.ts- this handles compound words and is critical for correct behavior@interweb/inflectionis the desired name before publishingTest plan: Run
cd packages/inflection && pnpm testlocally. After publishing, updategraphile-simple-inflectorand verify that GraphQL schemas still useschemata(notschemas) for the Database type's relation field.Notes
This is the first of multiple PRs - the next steps are to:
graphile-simple-inflectorin constructive repo to use this librarygraphql-codegento use this library and remove the duplicatepluralize.tsLink to Devin run: https://app.devin.ai/sessions/0a2a8e7889894852863ad967c5e79636
Requested by: Dan Lynch (@pyramation)