dotansimha / dotansimha/graphql-code-generator-community
flutter-freezed plugin is incompatible Freezed (v3). (Minor change required)
- Dominant language
- TypeScript
- Stars
- 137
- Forks
- 195
- Avg merge
- 6h 20m
- Merged PRs (30d)
- 16
Description
**Is your feature request related to a problem? Please describe.**
The upgrade to the Freezed package from v2 to v3 comes with a breaking change in the syntax. Specifically, "Classes using the factory constructor now require a keyword sealed / abstract." [(details here)](https://github.com/rrousselGit/freezed/blob/master/packages/freezed/migration_guide.md)
**Describe the solution you'd like**
- Create a new major version of the flutter-freezed plugin that automatically includes `sealed`/`abstract` keyword.
- ~~Create a config flag that allows the user to specify if they want to add `sealed`/`abstract` before the class definition based on the version of Freezed they are using~~.
**Describe alternatives you've considered**
I've done a global replace on the file generated by the plugin add 'abstract' before the 'class' keyword.
So that this:
```typescript
@freezed
class Report with _$Report {
const Report._();
const factory Report({
required final String name
}) = _Report;
factory Report.fromJson(Map json) =>
_$ReportFromJson(json);
}
//...
```
Becomes:
```typescript
@freezed
abstract class Report with _$Report {
const Report._();
const factory Report({
required final String name
}) = _Report;
factory Report.fromJson(Map json) =>
_$ReportFromJson(json);
}
//...
```
...and that works as expected.
**Additional context**
The change to Freezed is described [here](https://github.com/rrousselGit/freezed/blob/master/packages/freezed/migration_guide.md).
----
To: @Parables
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.