strawberry-graphql / strawberry-django

Strawberry GraphQL Django extension
MIT License
391 stars 115 forks source link

fix: Add support for generated enums in mutation input #497

Closed cngai closed 3 months ago

cngai commented 3 months ago

Description

If GENERATE_ENUMS_FROM_CHOICES is set to True, mutations with enum input values will resolve the input type as an enum. When the input is parsed, it tries to save the field as an enum instead of a string value, causing Django to throw a ValidationError "Value 'ExampleEnum.VALUE' is not a valid choice.". This PR addresses this issue by parsing the enum and returning the enum value.

Types of Changes

Issues Fixed or Closed by This PR

Fix https://github.com/strawberry-graphql/strawberry-django/issues/491

Checklist

cngai commented 3 months ago

Hey @bellini666 - would you mind giving this PR a review when you get the chance? Really appreciate it!

codecov-commenter commented 3 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 87.98%. Comparing base (23c4126) to head (f624d12).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #497 +/- ## ========================================== + Coverage 87.97% 87.98% +0.01% ========================================== Files 37 37 Lines 3184 3187 +3 ========================================== + Hits 2801 2804 +3 Misses 383 383 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

cngai commented 3 months ago

Thanks @bellini666 !!