Skip to content

fix(graphql-codegen-client-preset): support document variable naming options - #675

Merged
Donny/강동윤 (kdy1) merged 3 commits into
mainfrom
kdy1/fix-issue-610
Oct 27, 2026
Merged

Donny/강동윤 (kdy1) merged 3 commits into
mainfrom
kdy1/fix-issue-610

Conversation

@kdy1

@kdy1 Donny/강동윤 (kdy1) commented Oct 27, 2026 •

Copy link
Copy Markdown
Member

The plugin always imports operation and fragment documents with Document and FragmentDoc suffixes. With documentVariableSuffix: "" in Codegen, it imports GetUserDocument even though Codegen exports GetUser.

Add documentVariablePrefix, documentVariableSuffix, fragmentVariablePrefix, fragmentVariableSuffix, dedupeOperationSuffix, and omitOperationSuffix with backward-compatible defaults. Apply the naming convention to the combined prefix, name, and suffix. Match Codegen's fragment suffix deduplication and omission rules; these flags leave operation document variable names unchanged.

Document the options in README.tmpl.md and add regression tests for empty suffixes, custom affixes on all operation kinds, naming conventions, case-insensitive fragment deduplication, and omission precedence.

Rust validation passed on a4de3c6. The follow-up commit changes documentation only; Rust tests were not rerun.

Validation:

  • cargo test -p swc_plugin_graphql_codegen_client_preset — passed, 21 tests.
  • rustfmt --edition 2021 --check contrib/graphql-codegen-client-preset/src/lib.rs contrib/graphql-codegen-client-preset/src/tests.rs — passed.
  • git diff --check — passed. The documentation follow-up also passed git diff --cached --check.

Closes #610

@changeset-bot

changeset-bot Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 5f6b034

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-27T03:45:53.403185Z 5f6b034 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a4de3c687c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "Codex (@codex) review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "Codex (@codex) address that feedback".

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5f6b034bac

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "Codex (@codex) review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "Codex (@codex) address that feedback".

Comment on lines +89 to +93
"change-case-all#pascalCase" => s
.split('_')
.map(to_pascal_case)
.collect::<Vec<_>>()
.join("_"),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Retain underscore conversion for object naming conventions

When both configurations use namingConvention: { "typeNames": "change-case-all#pascalCase" }, an operation named Get_User now imports Get_UserDocument, whereas Codegen exports GetUserDocument. Codegen's naming implementation defaults underscore transformation to true for an explicitly configured object typeNames converter, unlike string conventions. Since as_type_name_convention() discards that distinction, unconditionally preserving underscores here breaks previously working imports even without custom affixes. Retain the object-specific underscore policy when resolving the naming convention.

Useful? React with 👍 / 👎.

@kdy1
Donny/강동윤 (kdy1) merged commit a6eb8fa into main Oct 27, 2026
12 of 13 checks passed
@kdy1
Donny/강동윤 (kdy1) deleted the kdy1/fix-issue-610 branch October 27, 2026 03:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

graphql-codegen-client-preset: support configurable document/fragment variable suffixes

1 participant