Skip to content
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

Code generated for screaming-case enum names conflicts with built_value #224

Closed
zoechi opened this issue Apr 29, 2021 · 4 comments · Fixed by #225
Closed

Code generated for screaming-case enum names conflicts with built_value #224

zoechi opened this issue Apr 29, 2021 · 4 comments · Fixed by #225

Comments

@zoechi
Copy link

zoechi commented Apr 29, 2021

  [SEVERE] built_value_generator:built_value on lib/src/api/graphql/schema/schema.schema.gql.dart (cached):
  Error in BuiltValueGenerator for /glucose/lib/src/api/graphql/schema/schema.schema.gql.dart.
  Please make the following changes to use built_value serialization:  1. Declare GENUM_EVENTLOG_EVENTTYPE.serializer as: static Serializer<GENUM_EVENTLOG_EVENTTYPE> get serializer => _$gENUMEVENTLOGEVENTTYPESerializer; got static Serializer<GENUM_EVENTLOG_EVENTTYPE> get serializer => _$genumEventlogEventtypeSerializer;
  2. Declare GENUM_EVENTLOG_EXERCISETYPE.serializer as: static Serializer<GENUM_EVENTLOG_EXERCISETYPE> get serializer => _$gENUMEVENTLOGEXERCISETYPESerializer; got static Serializer<GENUM_EVENTLOG_EXERCISETYPE> get serializer => _$genumEventlogExercisetypeSerializer;
  3. Declare GENUM_EVENTLOG_MEALTYPE.serializer as: static Serializer<GENUM_EVENTLOG_MEALTYPE> get serializer => _$gENUMEVENTLOGMEALTYPESerializer; got static Serializer<GENUM_EVENTLOG_MEALTYPE> get serializer => _$genumEventlogMealtypeSerializer;
  [SEVERE] Failed after 4.6s
  pub finished with exit code 1

These enum names come from strapi.io and can not be influenced except by changing Strapi code

ferry: 0.9.4
built_value: 7.1.0

@zoechi
Copy link
Author

zoechi commented Apr 29, 2021

Actually Stapi allows to set a custom name, but I think this is still a legit issue

@knaeckeKami
Copy link
Collaborator

knaeckeKami commented May 10, 2021

can confirm. The issue is that built_value used a slightly different implementation of toCamelCase than recase.

built_value:
https://github.com/google/built_value.dart/blob/3072533c3113fda8f1806125634d75e1a43d7b50/built_value_generator/lib/src/serializer_source_class.dart#L535

recase:
https://github.com/techniboogie-dart/recase/blob/master/lib/recase.dart#L73

difference example:
https://dartpad.dartlang.org/8dd8438d92ad5e16e9a1077c4735aa94?null_safety=true

We should switch to the same camelCase logic in the code builder
https://github.com/gql-dart/gql/blob/master/codegen/gql_code_builder/lib/src/schema/enum.dart#L97

also built_class probably has the same issue here:

(b) => b..body = Code("_\$${className.camelCase}Serializer"),

@smkhalsa smkhalsa transferred this issue from gql-dart/ferry May 11, 2021
@smkhalsa
Copy link
Member

thanks @knaeckeKami for digging into this.

Can you please confirm that #225 resolves this issue?

@knaeckeKami
Copy link
Collaborator

yes, this fixes it!

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

Successfully merging a pull request may close this issue.

3 participants