strawberry-graphql / strawberry-django

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

fix: Set files early on mutations to allow clean methods to validate them #566

Closed bellini666 closed 3 months ago

bellini666 commented 3 months ago

This is a regression from: https://github.com/strawberry-graphql/strawberry-django/pull/394

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

Summary by Sourcery

This pull request addresses a regression issue by ensuring files are set early in mutations to allow validation methods to function correctly. It also includes a new test to verify the update functionality when unsetting an optional file.

sourcery-ai[bot] commented 3 months ago

Reviewer's Guide by Sourcery

This pull request addresses a regression issue by setting files early on mutations to allow clean methods to validate them. The changes primarily involve removing the handling of file fields from the prepare_create_update function and its associated calls in the create and update functions. Additionally, a new test case is added to ensure the correct behavior when unsetting an optional file.

File-Level Changes

Files Changes
strawberry_django/mutations/resolvers.py Refactored the handling of file fields in the prepare_create_update, create, and update functions to set files early on mutations, allowing clean methods to validate them.
tests/mutations/test_mutations.py Added a new test case to ensure the correct behavior when unsetting an optional file and fixed a typo in an existing test case.

Tips - Trigger a new Sourcery review by commenting `@sourcery-ai review` on the pull request. - You can change your review settings at any time by accessing your [dashboard](https://app.sourcery.ai): - Enable or disable the Sourcery-generated pull request summary or reviewer's guide; - Change the review language; - You can always [contact us](mailto:support@sourcery.ai) if you have any questions or feedback.
codecov-commenter commented 3 months ago

Codecov Report

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

Project coverage is 88.87%. Comparing base (db5ca05) to head (11486f9).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #566 +/- ## ========================================== + Coverage 88.85% 88.87% +0.02% ========================================== Files 41 41 Lines 3544 3533 -11 ========================================== - Hits 3149 3140 -9 + Misses 395 393 -2 ```

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