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

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

Merged
merged 1 commit into from
Jun 29, 2024

Conversation

bellini666
Copy link
Member

@bellini666 bellini666 commented Jun 29, 2024

This is a regression from: #394

Fix #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.

  • Bug Fixes:
    • Fixed an issue where files were not set early enough in mutations, causing validation methods to fail.
  • Tests:
    • Added a test to verify the update functionality when unsetting an optional file.

@bellini666 bellini666 self-assigned this Jun 29, 2024
Copy link
Contributor

sourcery-ai bot commented Jun 29, 2024

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:
    • Enable or disable the Sourcery-generated pull request summary or reviewer's guide;
    • Change the review language;
  • You can always contact us if you have any questions or feedback.

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @bellini666 - I've reviewed your changes and they look great!

Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 Security: all looks good
  • 🟡 Testing: 1 issue found
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment to tell me if it was helpful.

tests/mutations/test_mutations.py Show resolved Hide resolved
@codecov-commenter
Copy link

codecov-commenter commented Jun 29, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

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

Additional details and impacted files
@@            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     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@bellini666 bellini666 merged commit 6da9776 into main Jun 29, 2024
22 checks passed
@bellini666 bellini666 deleted the fix_file_field_regression branch June 29, 2024 13:21
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 this pull request may close these issues.

FileField Model validation doesn't work with default resolvers
2 participants