Skip to content

feat(graphql-codegen): configurable document/fragment variable naming#611

Open
m-sanders wants to merge 1 commit intoswc-project:mainfrom
m-sanders:feat/graphql-codegen-configurable-suffix
Open

feat(graphql-codegen): configurable document/fragment variable naming#611
m-sanders wants to merge 1 commit intoswc-project:mainfrom
m-sanders:feat/graphql-codegen-configurable-suffix

Conversation

@m-sanders
Copy link
Copy Markdown

Close #610

Adds missing config options matching @graphql-codegen/client-preset:

Option Default
documentVariablePrefix ""
documentVariableSuffix "Document"
fragmentVariablePrefix ""
fragmentVariableSuffix "FragmentDoc"
dedupeOperationSuffix false
omitOperationSuffix false

dedupeOperationSuffix and omitOperationSuffix only affect fragment variable names, matching upstream codegen's getFragmentVariableName behavior in base-visitor.ts.

All defaults match the previous hardcoded values.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 8, 2026

🦋 Changeset detected

Latest commit: f8ac160

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@swc-contrib/plugin-graphql-codegen-client-preset Minor

Not sure what this means? Click here to learn what changesets are.

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

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Apr 8, 2026

CLA assistant check
All committers have signed the CLA.

Copy link
Copy Markdown

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

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: 296dd09b68

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

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

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

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread contrib/graphql-codegen-client-preset/src/lib.rs
Comment thread contrib/graphql-codegen-client-preset/src/lib.rs
The plugin previously hardcoded "Document" and "FragmentDoc" suffixes
when generating import identifiers. This meant setting e.g.
`documentVariableSuffix: ''` in codegen config would cause a mismatch.

Adds six new config options matching @graphql-codegen/client-preset:

- documentVariablePrefix (default: "")
- documentVariableSuffix (default: "Document")
- fragmentVariablePrefix (default: "")
- fragmentVariableSuffix (default: "FragmentDoc")
- dedupeOperationSuffix (default: false)
- omitOperationSuffix (default: false)

dedupeOperationSuffix and omitOperationSuffix only affect fragment
variable names, matching upstream codegen's getFragmentVariableName.

All defaults match previous hardcoded values — fully backwards compatible.
@m-sanders m-sanders force-pushed the feat/graphql-codegen-configurable-suffix branch from 296dd09 to f8ac160 Compare April 8, 2026 16:59
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

2 participants