Wrap calls to heck in a helper that keeps leading underscores intact#549
Open
Tails wants to merge 4 commits intographql-rust:mainfrom
Open
Wrap calls to heck in a helper that keeps leading underscores intact#549Tails wants to merge 4 commits intographql-rust:mainfrom
Tails wants to merge 4 commits intographql-rust:mainfrom
Conversation
added 2 commits
October 9, 2025 09:20
Fixes issue where GraphQL fields with leading underscores (like `_id`) were incorrectly converted to snake_case without preserving the prefix. Changes: - Added `to_snake_case_preserve_leading_underscores()` helper function - Updated all heck::to_snake_case() calls in codegen to use the wrapper - Preserves leading underscores for: - Input object field names - Response type field names - Fragment names - Variable names - Module names This fixes compatibility with TerminusDB GraphQL schema which uses `_id` fields that should remain as `_id` in generated Rust code. Related to: graphql-rust#498
Moved the duplicated helper function from 4 separate modules into the shared module to eliminate code duplication. Changes: - Added helper to graphql_client_codegen/src/codegen/shared.rs - Made shared module pub(crate) to allow access from generated_module.rs - Removed duplicates from inputs.rs, selection.rs, codegen.rs, generated_module.rs - Updated all modules to import from shared module No functional changes, purely code organization improvement.
Member
|
I enabled test runs for this PR. It looks like there are compilation errors. If this is testable, a test case or two for this fix would be helpful. |
added 2 commits
October 10, 2025 00:14
After centralizing the to_snake_case_preserve_leading_underscores helper function, several unused imports of heck traits remained in the codebase. This commit removes those unused imports to clean up compiler warnings. Changes: - Removed unused ToSnakeCase import from codegen/inputs.rs - Removed unused heck::* import from codegen/selection.rs - Removed unused heck::ToSnakeCase import from codegen.rs - Removed unused heck::* import from generated_module.rs - Updated introspection test to use __schema field name instead of schema, correctly validating that leading underscores are preserved All tests pass: cargo test --all --tests --examples
Apply rustfmt formatting to all files to comply with project style guidelines.
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.
Fixes #498