dotansimha / dotansimha/graphql-code-generator-community
Flutter json_serializable use `JsonValue` as the json key of Enum
- Dominant language
- TypeScript
- Stars
- 137
- Forks
- 195
- Avg merge
- 6h 20m
- Merged PRs (30d)
- 16
Description
### Which packages are impacted by your issue?
@graphql-codegen/flutter-freezed
### Describe the bug
The current version of [json_serializable](https://pub.dev/packages/json_serializable) uses `JsonValue` as the Enum json serialize key.
### Your Example Website or App
https://stackblitz.com/edit/github-mc3hpg?file=app_models.dart
### Steps to Reproduce the Bug or Issue
Schema.graphql
```
enum BookCategory {
BusinessCareer
Family
}
```
Generate
```
enum BookCategory {
@JsonKey(name: 'BusinessCareer')
businessCareer,
@JsonKey(name: 'Family')
family,
}
```
freezed generate
```
const _$BookCategoryEnumMap = {
BookCategory.businessCareer: 'businessCareer',
BookCategory.family: 'family',
}
```
freezed use `$enumDecode(_$BookCategoryEnumMap, e);` to trans from json.
got error
```
Invalid argument(s): `BusinessCareer` is not one of the supported values: businessCareer, family,
```
### Expected behavior
```
enum BookCategory {
@JsonValue('BusinessCareer')
businessCareer,
@JsonValue('Family')
family,
}
```
### Screenshots or Videos
_No response_
### Platform
```
"@graphql-codegen/cli": "5.0.2",
"@graphql-codegen/flutter-freezed": "^4.0.0",
"@graphql-codegen/introspection": "4.0.3",
"@graphql-codegen/typescript": "4.0.6",
"@graphql-codegen/typescript-resolvers": "4.0.6",
```
### Codegen Config File
_No response_
### Additional context
_No response_
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.