dotansimha / dotansimha/graphql-code-generator
enumValues with different names in .graphql and .ts break in babel.
- Dominant language
- TypeScript
- Stars
- 11.3k
- Forks
- 1.4k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 23
Description
**Describe the bug**
Given:
```yml
schema:
- ./src/main.graphql
generates:
./src/types.ts:
plugins:
- typescript
- typescript-operations
config:
enumValues:
UserStatusNotOk: ./Enums#USER_STATUS_NOT_OK
UserStatusOk: ./Enums#UserStatusOk
```
It seems as if `enumValues` which do not have the same name in the `.ts` and `.graphql` files are now generating:
```ts
import { USER_STATUS_NOT_OK } from './Enums';
import UserStatusNotOk = USER_STATUS_NOT_OK; // <--
```
instead of the previous:
```ts
import { USER_STATUS_NOT_OK as UserStatusNotOk } from './Enums';
```
I am not sure if this is a bug, or expected behaviour, but it breaks the usage of those types with bable and `@babel/plugin-transform-typescript`.
**To Reproduce**
I have created a simple repo here:
https://github.com/philiiiiiipp/Grapqhl-Generator-Enum-Bug
**Expected behavior**
I would expect that this to still work with a project using babel and typescript.
**Additional information**
The last known working version was
```
"@graphql-codegen/cli": "^1.10.0",
"@graphql-codegen/typescript": "^1.10.0",
"@graphql-codegen/typescript-operations": "^1.10.0",
"@graphql-codegen/typescript-resolvers": "^1.10.0",
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.