strawberry-graphql / strawberry-django

Strawberry GraphQL Django extension
https://strawberry.rocks/docs/django
MIT License
406 stars 118 forks source link

Fix/489 auto enum value allowed chars #494

Closed fabien-michel closed 6 months ago

fabien-michel commented 6 months ago

Use regex to replace invalid characters in auto generated enums.

This occur because django's choice values are strings and can contain any chars.

Exemple This

class Choice(models.TextChoices):
   EN_US = "en-US", "English"

Choice.choices return (("en-US", "English"),), and hyphen is not a valid char for GraphQL naming convention. So it would fail. The PR replace non valid chars to _.

Types of Changes

Issues Fixed or Closed by This PR

Checklist

codecov-commenter commented 6 months ago

Codecov Report

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

Project coverage is 87.98%. Comparing base (fc23726) to head (dcae186).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #494 +/- ## ========================================== + Coverage 87.95% 87.98% +0.03% ========================================== Files 37 37 Lines 3172 3180 +8 ========================================== + Hits 2790 2798 +8 Misses 382 382 ```

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