-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[flutter-freezed] Can't handle multiple line comments #8330
Comments
cc @Parables |
@charlypoly @endigo, I know of these issues because I am also using the plugin for my project. @endigo, the plugin is quite simple, I would be very grateful if you could submit a PR for these fixes on the fluter-freezed-v3.0.0 branch. As a guide, find the related codes to the issues you mentioned here
Thank you for fishing out these issues. |
It's been 22 days since this issue was posted and I am not happy I haven't been able to fix it so I will squeeze some few hours in the mornings to attempt fixing the plugin. @charlypoly, what have I missed while I was away.... any breaking changes I should be aware of? |
@Parables, don't worry, no hurry! No, we didn't introduce breaking changes in the core packages, you are safe. |
Hey @Parables, just ran the plugin but it seems broken. Also cannot directly use the npm dep from github since it's a monorepo. When do you think the fix version will be released? |
Same problem! I'd like to see internal code, where can I find them? |
@auaicn please find the source of these issues in the comment quoted above. I'm currently under lots of pressure to meet multiple deadlines so I will be very grateful if you can help me out with a PR for these fixes |
I handled some issues on my branch and also updated tests.
Regarding Issue numbered 4 by @endigo
What @endigo says might be explained with below example @unfreezed
class NestedIntFilter with _$NestedIntFilter {
const NestedIntFilter._();
const factory NestedIntFilter({
int? equals,
int? gt,
int? gte,
- List<int>? in, // current result. It's as expected, but causes error
int? lt,
int? lte,
NestedIntFilter? not,
List<int>? notIn,
}) = _NestedIntFilter;
factory NestedIntFilter.fromJson(Map<String, Object?> json) => _NestedIntFilterFromJson(json);
} There's a lot of reserved keyword on dart language.
Is it okay if I append _(underscore) after like this? @unfreezed
class NestedIntFilter with _$NestedIntFilter {
const NestedIntFilter._();
const factory NestedIntFilter({
int? equals,
int? gt,
int? gte,
- List<int>? in, // current result. It's as expected, but causes error
+ List<int>? in_,
int? lt,
int? lte,
NestedIntFilter? not,
List<int>? notIn,
}) = _NestedIntFilter;
factory NestedIntFilter.fromJson(Map<String, Object?> json) => _NestedIntFilterFromJson(json);
} If there's better solution, let me know. Another handled Issues@unfreezed
class NestedIntFilter with _$NestedIntFilter {
const NestedIntFilter._();
const factory NestedIntFilter({
int? equals,
int? gt,
int? gte,
List<int>? in,
int? lt,
int? lte,
NestedIntFilter? not,
List<int>? notIn,
}) = _NestedIntFilter;
- factory NestedIntFilter.fromJson(Map<String, Object?> json) => _NestedIntFilterFromJson(json); // current result, but not follows freezed spec
+ factory NestedIntFilter.fromJson(Map<String, Object?> json) => _$NestedIntFilterFromJson(json); // follows current freezed spec
} @Parables It would be appreciate if you reply to me! |
I saw your PR as soon as you sent it but the power was out for 2 days and my battery drained before I could review your changes. Sincere apologies for not replying earlier. I value your effort and dedication, most importantly your time which is something I used to have a lot at my disposal but things took a sudden turn and right now, I am torn in between final year school projects, work projects and other in-production side gigs. It is part of my routine to check my GitHub notifications before I begin the day's work so please give me up to a day to respond. Once again, I am very grateful to you @auaicn |
Regarding Issue numbered 4 by @endigoThanks for clarifying this issue for me @auaicn . Appending or prepending an @munificent shared this same idea in this open issue. So we are torn between modifying our GraphQL schema to use keyword-friendly identifiers or waiting for the Dart team to find a way to escape Dart keywords to be used as identifiers. Using @unfreezed
class NestedIntFilter with _$NestedIntFilter {
const NestedIntFilter._();
const factory NestedIntFilter({
int? equals,
int? gt,
int? gte,
- List<int>? in, // current result. It's as expected, but causes error
+ @JsonKey(name: "in") List<int>? in_,
+ // OR
+ @JsonKey(name: "in") List<int>? someOtherName,
int? lt,
int? lte,
NestedIntFilter? not,
List<int>? notIn,
}) = _NestedIntFilter;
factory NestedIntFilter.fromJson(Map<String, Object?> json) => _$NestedIntFilterFromJson(json); // follows current freezed spec
} Using I hope this helps clears out any confusion. I am open to further discussions so please share your thoughts with me. PS:You can specify the |
Thanks for the guidance to avoid dart reserved-words. I'll try the solution |
@auaicn What do you have in mind? Implement a way to detect a Dart keyword and automatically wrap it in Since this is a problem-specific issue, I suggest we can add some notes to the guide something like a FAQ on how to address such problems. That's why this plugin is configurable so that the user can fine-tune the output as preferred |
I think it would be better if we can give option which can be set in yes, if parameter name is modified, it seems
|
@auaicn while that would work and address this problem, I doubt we should implement it. According to Gregory Young, the software must do 99% of the work, the remaining 1% should be done by the human. This issue can simply be addressed with the current version of the plugin by specifying the following in the config:
typeSpecificFreezedConfig: {
NestedIntFilter: {
fields: {
in: {
customDecorators: { # custom are used just as it given
'@JsonKey' : {
mapsToFreezedAs: 'custom', # custom are used just as it given
applyOn: ['class_factory_parameter', 'union_factory_parameter'],
arguments: ["name: 'in' "],
},
}
}
}
}
} This config should produce an output as below. Part of the output has been cropped for brevity @unfreezed
class NestedIntFilter with _$NestedIntFilter {
const NestedIntFilter._();
const factory NestedIntFilter({
...
@JsonKey(name: "in") List<int>? in_,
...
}) = _NestedIntFilter;
} |
Okay: I take it back, I missed the fact that this solution doesn't fix the issue. Moreover, it can be quite a boilerplate if you have more GraphQL types using Dart-valid keywords, specifying a config for each field seems unreasonably simple. @auaicn Please go ahead with your proposal. Let me know what you come up with. Once again, Sorry for disagreeing with your proposal initially. Your solution is the best simple fix for this issue |
@auaicn @endigo @gabsn I would like to notify you that this issue is being addressed in the new community repo found on flutter-freezed-v3.0.0-fix. If you have any issues, please forward is to the new repo instead. I am personally disappointed for not being able to manage this plugin but I would like to thank you all for patience. @endigo thanks for using this plugin and pointing out this issue |
@Parables, please know that we will migrate all community plugin-related issues to the new repo by the end of the week 😊 |
@charlypoly @endigo @gabsn @auaicn All the issues mentioned here have been fixed. There was an urgent need to rewrite this plugin again and I just couldn't squeeze in any time until now. This plugin started when I saw the myzod plugin and I decided to follow his steps to create this plugin. I also borrow a lot of ideas from existing plugins. This is the fourth iteration of the plugin and there are lots of The changes will be available on the community-repo so be sure to check it out in the morning. And please close this issue as completed @charlypoly. Thank you |
Expected
part 'app_models.freezed.dart';
Actual
part 'app_models.dart';
@JsonKey
in enums missing"
and,
end of the lineExpected
@JsonKey(name: "ACCOUNT_NOT_CONFIRMED") account_not_confirmed,
Actual
@JsonKey(name: ACCOUNT_NOT_CONFIRMED) account_not_confirmed
https://demo.saleor.io/graphql/
The text was updated successfully, but these errors were encountered: