Skip to content

refactor: migrate all camelize() calls to declarative toCamelCase/toPascalCase API#897

Merged
pyramation merged 3 commits intomainfrom
devin/1774491279-migrate-camelize-to-declarative-api
Mar 26, 2026
Merged

refactor: migrate all camelize() calls to declarative toCamelCase/toPascalCase API#897
pyramation merged 3 commits intomainfrom
devin/1774491279-migrate-camelize-to-declarative-api

Conversation

@pyramation
Copy link
Copy Markdown
Contributor

@pyramation pyramation commented Mar 26, 2026

Summary

Replaces all camelize() calls across the monorepo with inflekt's new declarative API (toCamelCase / toPascalCase), eliminating the confusing boolean second parameter. Also consolidates remaining duplicated case-transformation logic to use inflekt as the single source of truth.

Mapping applied:

  • camelize(x, true)toCamelCase(x) (36 call sites)
  • camelize(x) / camelize(x, false)toPascalCase(x) (5 call sites)

Files changed (excluding lockfile):

  • graphile/graphile-settings/src/plugins/custom-inflector.ts — 14 call sites migrated
  • graphql/query/src/query-builder.ts — 11 call sites migrated
  • graphql/query/src/ast.ts — 3 call sites migrated
  • graphql/query/src/generators/naming-helpers.ts — 2 call sites migrated + replaced inline screaming-snake regex with toScreamingSnake from inflekt
  • graphql/codegen/src/cli/shared.ts — 1 call site migrated + simplified camelizeArgv (removed redundant hyphen pre-processing since toCamelCase handles hyphens natively)
  • pgpm/export/src/graphql-naming.ts — 3 call sites migrated
  • pgpm/export/__tests__/export-parity.test.ts — 1 call site (test helper, not assertion)
  • pgpm/export/__tests__/cross-flow-parity.test.ts — 1 call site (test helper, not assertion)
  • pgpm/export/package.json — bumped inflekt ^0.3.3^0.5.1
  • postgres/pg-codegen/src/codegen/codegen.ts — replaced local toPascalCase copy with import from inflekt
  • postgres/pg-codegen/package.json — added inflekt as dependency

Behavioral note: The new functions handle both - and _ delimiters, whereas the old camelize only handled _. An audit of all call sites confirmed inputs are always snake_case, so this is safe.

Companion PR: constructive-io/dev-utils#72 (merged — inflekt@0.5.1 published with camelize removed entirely).

Updates since last revision

  • Bumped inflekt to ^0.5.1 across all 5 consuming packages (graphile-settings, graphql/query, graphql/codegen, pgpm/export, postgres/pg-codegen) and regenerated lockfile to resolve the newly published version.
  • Removed local toPascalCase from pg-codegen/codegen.ts — replaced with import { toPascalCase } from 'inflekt' and added inflekt as a dependency to pg-codegen.
  • Simplified camelizeArgv in shared.ts — the old code did key.replace(/-/g, '_') before calling toCamelCase, but toCamelCase already handles hyphens natively, so the wrapper was reduced to just toCamelCase.
  • Replaced inline screaming-snake regex in toOrderByEnumValue — now uses toScreamingSnake from inflekt instead of an inline .replace(/([a-z0-9])([A-Z])/g, '$1_$2').toUpperCase().

Review & Testing Checklist for Human

  • Verify toScreamingSnake equivalence in toOrderByEnumValue: The old inline regex ([a-z0-9])([A-Z]) only inserts _ at lower→upper transitions, while inflekt's toScreamingSnake inserts _ before every uppercase letter. These behave identically for typical camelCase field names (displayName, createdAt) but differ for consecutive-uppercase inputs (e.g. "ABCField" → old: "ABC_FIELD", new: "A_B_C_FIELD"). Verify your schema field names don't include such patterns.
  • Verify camelizeArgv simplification: Confirm that toCamelCase("schema-file") produces "schemaFile" — same as the old path of "schema-file""schema_file"toCamelCase"schemaFile". Should be identical but worth a spot-check with CLI args.
  • Verify PascalCase mapping in pg-codegen/codegen.ts: The local toPascalCase used [_-](\w) while inflekt's uses [-_](.). Both handle underscore and hyphen; the difference is \w vs . for the captured char. Should be equivalent for identifier-safe inputs — verify pg table names don't contain special chars.
  • Run the PostGraphile schema against a real database to confirm inflector output hasn't changed (field names, query names, mutation names should all be identical).

Notes

  • No test assertions were modified — only test helper utilities that convert PG rows to camelCase.
  • Requires inflekt@0.5.1 (published, companion dev-utils PR already merged).
  • The camelizeArgv function name in shared.ts was intentionally kept as-is — it's a local function name describing what it does, not an inflekt API reference.

Link to Devin session: https://app.devin.ai/sessions/e3dd5ed7753043bd8d2166793364cd42
Requested by: @pyramation

Replace all camelize(x, true) with toCamelCase(x) and camelize(x) with
toPascalCase(x) across the codebase, using inflekt's new declarative API.

Files updated:
- graphile-settings/custom-inflector.ts (14 call sites)
- graphql/query/ast.ts (3 call sites)
- graphql/query/query-builder.ts (11 call sites)
- graphql/query/generators/naming-helpers.ts (2 call sites)
- graphql/codegen/src/cli/shared.ts (1 call site)
- pgpm/export/src/graphql-naming.ts (3 call sites)
- pgpm/export/__tests__/export-parity.test.ts (1 call site)
- pgpm/export/__tests__/cross-flow-parity.test.ts (1 call site)
- pgpm/export/package.json (bump inflekt to ^0.5.0)
@devin-ai-integration
Copy link
Copy Markdown
Contributor

🤖 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

- pg-codegen: replace local toPascalCase with import from inflekt
- codegen CLI: simplify camelizeArgv (toCamelCase already handles hyphens)
- naming-helpers: use toScreamingSnake from inflekt instead of inline regex
@pyramation pyramation merged commit c20a3e9 into main Mar 26, 2026
44 checks passed
@pyramation pyramation deleted the devin/1774491279-migrate-camelize-to-declarative-api branch March 26, 2026 02:58
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.

1 participant