Skip to content

Conversation

@pyramation
Copy link
Contributor

@pyramation pyramation commented Jan 7, 2026

Summary

Adds a new @interweb/inflection package that provides pluralization and singularization utilities with PostGraphile-compatible Latin suffix handling. This library is intended to be shared between graphile-simple-inflector and @constructive-io/graphql-codegen to ensure consistent inflection behavior across the codebase.

The library includes:

  • singularize/pluralize with Latin suffix overrides in both directions (schemata↔schema, criteria↔criterion, etc.)
  • singularizeLast/pluralizeLast for compound word handling (only transforms the last word)
  • distinctPluralize for cases where singular equals plural
  • Case transformations (lcFirst, ucFirst, fixCapitalisedPlural)
  • GraphQL naming helpers (toFieldName, toQueryName)

Updates since last revision

Added LATIN_PLURAL_OVERRIDES to the pluralize function so that Latin-style plurals are used (e.g., schemaschemata, criterioncriteria). This maintains backward compatibility with PostGraphile's expected GraphQL field names. Without this fix, upgrading would cause breaking changes where fields like schemata would become schemas.

Review & Testing Checklist for Human

  • Verify the LATIN_PLURAL_OVERRIDES list matches LATIN_SUFFIX_OVERRIDES (they should be inverses of each other)
  • Test that pluralize('schema') returns 'schemata' and pluralize('Schema') returns 'Schemata' (case preservation)
  • Review the changeLastWord regex pattern in pluralize.ts - this handles compound words and is critical for correct behavior
  • Confirm package name @interweb/inflection is the desired name before publishing

Test plan: Run cd packages/inflection && pnpm test locally. After publishing, update graphile-simple-inflector and verify that GraphQL schemas still use schemata (not schemas) for the Database type's relation field.

Notes

This is the first of multiple PRs - the next steps are to:

  1. Update graphile-simple-inflector in constructive repo to use this library
  2. Update graphql-codegen to use this library and remove the duplicate pluralize.ts

Link to Devin run: https://app.devin.ai/sessions/0a2a8e7889894852863ad967c5e79636
Requested by: Dan Lynch (@pyramation)

@devin-ai-integration
Copy link

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@pyramation pyramation merged commit ae969bf into main Jan 7, 2026
36 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants