graphql-code-generator: [flutter-freezed] Can't handle multiple line comments

  1. Wrong part code generated Expected part 'app_models.freezed.dart'; Actual part 'app_models.dart';
  2. Can’t handle multiline comments
  3. @JsonKey in enums missing " and , end of the line Expected @JsonKey(name: "ACCOUNT_NOT_CONFIRMED") account_not_confirmed, Actual @JsonKey(name: ACCOUNT_NOT_CONFIRMED) account_not_confirmed
  4. Some key words generated in enums (in,is,do,void,default) but it’s depends on what graphql server gives https://demo.saleor.io/graphql/

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 3
  • Comments: 18 (13 by maintainers)

Most upvoted comments

I handled some issues on my branch and also updated tests.

  • 1. addFreezedImportStatements
  • 2. Every block generates its own comments, freezed Class block, factory block, parameter block
  • 3. @JsonKey
  • 4. Not sure I understand what you said here, please elaborate on that for me

Regarding Issue numbered 4 by @endigo

Some key words generated in enums (in,is,do,void,default) but it’s depends on what graphql server gives

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. see here dart language keywords

abstract, else, import, show, as, enum, in, static, assert, export, interface, super, async, extends, is, switch, await, extension, late, sync, break, external, library, this, case, factory, mixin, throw, catch, false, new, true, class, final, null, try, const, finally, on, typedef, continue, for, operator, var,

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!

@charlypoly @endigo, I know of these issues because I am also using the plugin for my project. However, I am currently occupied with other activities that is why I haven’t fixed these issues.

@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

  1. addFreezedImportStatements
  2. Every block generates its own comments, freezed Class block, factory block, parameter block
  3. @JsonKey
  4. Not sure I understand what you said here, please elaborate on that for me

Thank you for fishing out these issues. Your contribution is greatly appreciated 🙏

@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

@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 @auaicn thanks for your help and time. @charlypoly thanks for your dedication

@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 changes improvements compared to the previous versions so I guess this would be version 3.x or 4.x maybe @charlypoly

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

@Parables, please know that we will migrate all community plugin-related issues to the new repo by the end of the week 😊

@Parables It would be appreciated 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

Same problem! I’d like to see internal code, where can I find them?

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?

@charlypoly @endigo, I know of these issues because I am also using the plugin for my project. However, I am currently occupied with other activities that is why I haven’t fixed these issues.

@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

  1. addFreezedImportStatements
  2. Every block generates its own comments, freezed Class block, factory block, parameter block
  3. @JsonKey
  4. Not sure I understand what you said here, please elaborate on that for me

Thank you for fishing out these issues. Your contribution is greatly appreciated 🙏