strawberry-graphql / strawberry

A GraphQL library for Python that leverages type annotations 🍓
https://strawberry.rocks
MIT License
3.95k stars 525 forks source link

Fix operation execution #3628

Closed patrick91 closed 2 weeks ago

patrick91 commented 2 weeks ago

Closes #3625

Summary by Sourcery

Fix the async operation execution to ensure extensions receive the result from the execution context and add a corresponding test to verify error masking. Document the patch release in a new RELEASE.md file.

Bug Fixes:

Documentation:

Tests:

sourcery-ai[bot] commented 2 weeks ago

Reviewer's Guide by Sourcery

This pull request fixes an issue with operation execution in async mode, ensuring that extensions receive the correct result from the execution context. It also adds a new async test for the MaskErrors extension.

File-Level Changes

Change Details Files
Fix async operation execution to properly handle results from execution context
  • Move result handling outside of the try-except block
  • Rename 'res' variable to 'result' for clarity
  • Ensure _handle_execution_result is called after all operations are completed
strawberry/schema/execute.py
Add async test for MaskErrors extension
  • Create new async test function test_mask_all_errors_async
  • Test MaskErrors extension behavior in async context
tests/schema/extensions/test_mask_errors.py
Add release notes for the patch
  • Create RELEASE.md file
  • Specify release type as patch
  • Describe the fix for async execution and extensions
RELEASE.md

Tips - Trigger a new Sourcery review by commenting `@sourcery-ai review` on the pull request. - Continue your discussion with Sourcery by replying directly to review comments. - 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.
botberry commented 2 weeks ago

Thanks for adding the RELEASE.md file!

Here's a preview of the changelog:


This release fixes an issue that prevented extensions to receive the result from the execution context when executing operations in async.

Here's the tweet text:

🆕 Release (next) is out! Thanks to @patrick91 for the PR 👏

Get it here 👉 https://strawberry.rocks/release/(next)
codecov[bot] commented 2 weeks ago

Codecov Report

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

Project coverage is 94.77%. Comparing base (eb4f558) to head (d338b6d).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #3628 +/- ## ========================================== - Coverage 96.75% 94.77% -1.99% ========================================== Files 521 517 -4 Lines 33715 32573 -1142 Branches 5622 3768 -1854 ========================================== - Hits 32622 30871 -1751 - Misses 861 1408 +547 - Partials 232 294 +62 ```
codspeed-hq[bot] commented 2 weeks ago

CodSpeed Performance Report

Merging #3628 will not alter performance

Comparing fix/mask-error (d338b6d) with main (eb4f558)

Summary

✅ 15 untouched benchmarks

patrick91 commented 2 weeks ago

Closed in favour of #3629