defaultWeightUnit field.GraphQL error: Expected a value of type "WeightUnitsEnum" but received: kgThis is also true for all other languages that have translations for any weight units (kg, oz, lb, g). In site settings when you change default weight unit to something else, the GraphQl error changes to '... but received: lb/oz/g'. For example in German:
https://github.com/mirumee/saleor/blob/5b5ed728ef9d7fd4b50305f7367ca5c46fe4fcf6/locale/de/LC_MESSAGES/django.po#L605
Changing this from 'Kg' to 'kg' (or any translated line back to 'kg', 'oz' , etc) and recompiling messages fixes this GraphQL error for me, but I suppose it should work with translated lines also? It is marked with pgettext_lazy:
https://github.com/mirumee/saleor/blob/5b5ed728ef9d7fd4b50305f7367ca5c46fe4fcf6/saleor/core/weight.py#L26
But from what I can see Dashboard 2.0 isn't translated yet, because even after changing language and getting these errors I have only English in there. But I assume that just reverting these lines back to non-translated state isn't a good fix.
Could you tell me if I am on the right track here: for that query to work with translation it must be added to graphql/translations.py?
Thank's for the clue! Enum values should be independent of the locale. I think we should get rid of enum.Enum occurrences and generate all enums for Graphene such as ones in saleor/graphql/core/enums.py. E.g. I quickly checked that everything works fine if I remove WeightUnitsEnum from weights.py and instead add this in graphql/core/enums.py:
WeightUnitsEnum = graphene.Enum(
'WeightUnitsEnum',
[(str_to_enum(unit[0]), unit[0]) for unit in WeightUnits.CHOICES])
Most helpful comment
Thank's for the clue! Enum values should be independent of the locale. I think we should get rid of
enum.Enumoccurrences and generate all enums for Graphene such as ones insaleor/graphql/core/enums.py. E.g. I quickly checked that everything works fine if I removeWeightUnitsEnumfromweights.pyand instead add this ingraphql/core/enums.py: