refactor: migrate all camelize() calls to declarative toCamelCase/toPascalCase API#897
Merged
pyramation merged 3 commits intomainfrom Mar 26, 2026
Merged
Conversation
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)
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:
|
3 tasks
- 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
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
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 migratedgraphql/query/src/query-builder.ts— 11 call sites migratedgraphql/query/src/ast.ts— 3 call sites migratedgraphql/query/src/generators/naming-helpers.ts— 2 call sites migrated + replaced inline screaming-snake regex withtoScreamingSnakefrom inflektgraphql/codegen/src/cli/shared.ts— 1 call site migrated + simplifiedcamelizeArgv(removed redundant hyphen pre-processing sincetoCamelCasehandles hyphens natively)pgpm/export/src/graphql-naming.ts— 3 call sites migratedpgpm/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.1postgres/pg-codegen/src/codegen/codegen.ts— replaced localtoPascalCasecopy with import from inflektpostgres/pg-codegen/package.json— addedinflektas dependencyBehavioral note: The new functions handle both
-and_delimiters, whereas the oldcamelizeonly 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
camelizeremoved entirely).Updates since last revision
^0.5.1across all 5 consuming packages (graphile-settings,graphql/query,graphql/codegen,pgpm/export,postgres/pg-codegen) and regenerated lockfile to resolve the newly published version.toPascalCasefrompg-codegen/codegen.ts— replaced withimport { toPascalCase } from 'inflekt'and added inflekt as a dependency to pg-codegen.camelizeArgvinshared.ts— the old code didkey.replace(/-/g, '_')before callingtoCamelCase, buttoCamelCasealready handles hyphens natively, so the wrapper was reduced to justtoCamelCase.toOrderByEnumValue— now usestoScreamingSnakefrom inflekt instead of an inline.replace(/([a-z0-9])([A-Z])/g, '$1_$2').toUpperCase().Review & Testing Checklist for Human
toScreamingSnakeequivalence intoOrderByEnumValue: The old inline regex([a-z0-9])([A-Z])only inserts_at lower→upper transitions, while inflekt'stoScreamingSnakeinserts_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.camelizeArgvsimplification: Confirm thattoCamelCase("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.pg-codegen/codegen.ts: The localtoPascalCaseused[_-](\w)while inflekt's uses[-_](.). Both handle underscore and hyphen; the difference is\wvs.for the captured char. Should be equivalent for identifier-safe inputs — verify pg table names don't contain special chars.Notes
camelizeArgvfunction name inshared.tswas 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