Skip to content
This repository has been archived by the owner on Oct 2, 2024. It is now read-only.

Feature request: Annotate unknownEnumValue on lists #246

Closed
budde377 opened this issue Jan 13, 2021 · 4 comments
Closed

Feature request: Annotate unknownEnumValue on lists #246

budde377 opened this issue Jan 13, 2021 · 4 comments

Comments

@budde377
Copy link
Contributor

Thanks for a great project. I've recently encountered an argument error with parsing enum values in lists, e.g.

enum E {
  V1
}

type T {
  enum: E!
  listOfEnums: [E!]!
}

schema {
  query: T
}

fragment F on T {
    listOfEnums
    enum
}

query Q {
    ...F
}

Here the above will generate the code

mixin FMixin {
  List<E> listOfEnums;
  @JsonKey(name: 'enum', unknownEnumValue: E.artemisUnknown)
  E kw$enum;
}

...

enum E {
  @JsonValue('V1')
  v1,
  @JsonValue('ARTEMIS_UNKNOWN')
  artemisUnknown,
}

I might be out of the loop, but it looks to me that this was removed in #85, since then it seems to be supported by json_serializable (google/json_serializable.dart#585), and it does indeed seem to work locally.

Can this functionality be added back? I.e. so the generated code will be

mixin FMixin {
  @JsonKey(name: 'listOfEnums', unknownEnumValue: E.artemisUnknown) 
 List<E> listOfEnums;
  @JsonKey(name: 'enum', unknownEnumValue: E.artemisUnknown)
  E kw$enum;
}```
@comigor
Copy link
Owner

comigor commented Jan 13, 2021

Hello @budde377!
Yeah, given this was fixed on json_serializable in August, it should be reverted here as well.
Could you open a PR with this fix? I'd greatly appreciate that!

@budde377
Copy link
Contributor Author

Sure, I'll give it a go!

@vasilich6107
Copy link
Collaborator

Hi @budde377
Could you check if the latest release works for you?

@budde377
Copy link
Contributor Author

@vasilich6107 Just checked, the latest release correctly annotated the field! Thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants