You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You might decide that this is an issue in the SWC plugin instead of the typescript-operations and babel-plugin packages
Summary
When an operation name has two consecutive capital letters, the generated TS variable name for the document seems to lose the 2nd capital letter. For example, query findUserByID creates a variable named const FindUserByIdDocument.
This behaviour is consistent with the babel plugin, so not a huge issue, but it is inconsistent with the SWC plugin.
In my opinion the SWC implementation makes sense, but either one is fine as long as they are consistent.
I haven't been able to create a reproduction with the SWC plugin, since I'm not able to get it to work at all (conflict with swc_core), but I do have a fork of it that we use internally and I'm able to reproduce reliably using it.
Which packages are impacted by your issue?
@graphql-codegen/typescript-operations, @graphql-codegen/client-preset
Describe the bug
You might decide that this is an issue in the SWC plugin instead of the
typescript-operations
and babel-plugin packagesSummary
When an operation name has two consecutive capital letters, the generated TS variable name for the document seems to lose the 2nd capital letter. For example,
query findUserByID
creates a variable namedconst FindUserByIdDocument
.This behaviour is consistent with the babel plugin, so not a huge issue, but it is inconsistent with the SWC plugin.
In my opinion the SWC implementation makes sense, but either one is fine as long as they are consistent.
I haven't been able to create a reproduction with the SWC plugin, since I'm not able to get it to work at all (conflict with swc_core), but I do have a fork of it that we use internally and I'm able to reproduce reliably using it.
Your Example Website or App
https://codesandbox.io/p/devbox/goofy-agnesi-n9gkhp
Steps to Reproduce the Bug or Issue
Expected behavior
With input
I would expect the variable to be called
FindUserByIDDocument
(note the case ofID
).Screenshots or Videos
No response
Platform
graphql
version: graphql@16.6.0@graphql-codegen/*
version(s): 4.0.1Codegen Config File
Additional context
SWC Plugin Test Fixture
A test fixture for SWC plugin would be this, which I am able to replicate with
cargo test
locally:and output
A quick fix would be changing the capitalize function to match the other two implementations
graphql-code-generator/packages/presets/swc-plugin/src/lib.rs
Lines 18 to 20 in 7a23422
(please also note there's a minor typo in that function name)
The text was updated successfully, but these errors were encountered: