Use schema-inferred naming/inflection in graphql-codegen generators#754
Merged
pyramation merged 1 commit intomainfrom Feb 28, 2026
Merged
Conversation
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:
|
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.
Use schema-inferred naming in graphql-codegen generators
Summary
The codegen generators (
mutations.ts,select.ts) hardcoded all GraphQL operation names, input types, and patch field names via string concatenation (e.g.`create${table.name}`,`${table.name}Filter`). Meanwhile,infer-tables.tsalready populatestable.queryandtable.inflectionwith the actual names discovered from the GraphQL schema via introspection. The generators simply ignored these fields.This PR introduces a new
naming-helpers.tsmodule (back-ported from Dashboard'squery-generator.ts) that prefers schema-discovered names and falls back to local inflection. All hardcoded naming in the generators is replaced with calls to these helpers.Changes:
naming-helpers.ts(new): 13 server-aware naming functions (toCamelCasePlural,toCamelCaseSingular,toCreateMutationName,toPatchFieldName,toFilterTypeName,toOrderByTypeName, etc.) withnormalizeInflectionValuesafety wrapper and guards against naive pluralization drift.mutations.ts: All 3 mutation builders (create,update,delete) now use naming helpers for mutation names, input type names, and singular field names. Removed directinflektimport.select.ts:generateIntrospectionSchema,generateSelectQueryAST,generateFindOneQueryAST,generateCountQueryASTall use naming helpers. Patch field name is now entity-specific (e.g.userPatchinstead of hardcodedpatch). OldtoCamelCasePlural/toOrderByTypeNamere-exported for backward compat.field-selector.ts:isRelationalFieldnow uses aWeakMap-cachedSet<string>for O(1) lookups instead of.some()linear scans.getRelatedTableScalarFieldsalso uses Sets for dedup.Review & Testing Checklist for Human
toUpdateInputTypeNameandtoDeleteInputTypeNamedon't needtableparameter. UnliketoCreateInputTypeNamewhich checkstable.inflection.createInputType, the update/delete variants are still hardcoded. Check whetherTableInflectioncarries equivalent fields for these and whether they should also be schema-aware.table.query.all !== pluralize(camelize(table.name)). Verify generated queries use the correct server names.buildPostGraphileUpdate. The return type's variables changed from{ input: { id: string | number; patch: Record<string, unknown> } }to{ input: { id: string | number } & Record<string, unknown> }. This is more flexible (supports entity-specific patch field names) but consumers who relied on thepatchproperty name in the type will lose that type safety. Verify this is acceptable.table.inflection.patchTypeexists.select.tsline 138 usestable.inflection?.patchType— confirm this field is actually populated byinfer-tables.tsor that the fallback to${modelName}Patchis always correct.Notes
"activitys"→"activities") and miscased server values ("deliveryzones"→"deliveryZones"), but these guards could theoretically reject valid server names in edge cases. Worth spot-checking the guard logic.