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

Check multipart subscriptions using accept header #3627

Merged
merged 1 commit into from
Sep 13, 2024

Conversation

patrick91
Copy link
Member

@patrick91 patrick91 commented Sep 12, 2024

Description

Types of Changes

  • Core
  • Bugfix
  • New feature
  • Enhancement/optimization
  • Documentation

Issues Fixed or Closed by This PR

Checklist

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • I have tested the changes and verified that they work and don't break anything (as well as I can manage).

Summary by Sourcery

Update the multipart subscription detection logic to use the 'accept' header instead of the 'content-type' header, ensuring compliance with the latest specification. Adjust the corresponding test to reflect this change and document the fix in the release notes.

Bug Fixes:

  • Fix the detection of multipart subscriptions by checking the 'accept' header instead of the 'content-type' header to align with the latest specification changes.

Documentation:

  • Add a release note indicating the patch release that fixes multipart subscription checks to comply with the latest specification.

Tests:

  • Update the test for multipart subscriptions to use the 'accept' header for protocol detection.

Copy link
Contributor

sourcery-ai bot commented Sep 12, 2024

Reviewer's Guide by Sourcery

This pull request updates the handling of multipart subscriptions to align with the latest changes in the specification. The main change is to use the 'Accept' header instead of the 'Content-Type' header to determine if a request is a multipart subscription.

File-Level Changes

Change Details Files
Update multipart subscription detection logic
  • Use 'Accept' header instead of 'Content-Type' for detecting multipart subscriptions
  • Move multipart subscription check before request method handling
  • Remove redundant checks for multipart subscriptions in different request methods
strawberry/http/async_base_view.py
Update test case for multipart subscriptions
  • Change 'Content-Type' header to 'Accept' header in test case
  • Set 'Content-Type' to 'application/json' in test case
tests/http/test_multipart_subscription.py
Add release notes
  • Create RELEASE.md file
  • Specify release type as 'patch'
  • Describe the change as fixing multipart subscription checking
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:
    • 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 @patrick91 - I've reviewed your changes - here's some feedback:

Overall Comments:

  • Consider optimizing the header processing by only lowercasing the 'accept' header instead of all headers.
  • It might be beneficial to add more test cases to cover different scenarios for multipart subscriptions.
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: 1 issue found

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.

@@ -64,7 +64,8 @@ async def test_multipart_subscription(
method=method,
query='subscription { echo(message: "Hello world", delay: 0.2) }',
headers={
"content-type": "multipart/mixed;boundary=graphql;subscriptionSpec=1.0,application/json",
"accept": "multipart/mixed;boundary=graphql;subscriptionSpec=1.0,application/json",
"content-type": "application/json",
},
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion (testing): Update test to use 'accept' header instead of 'content-type' for multipart subscriptions

The test has been updated to reflect the changes in the main code, where multipart subscriptions are now determined by the 'accept' header instead of the 'content-type'. This is a good change, but we should consider adding more test cases to cover different scenarios.

RELEASE.md Show resolved Hide resolved
@botberry
Copy link
Member

Thanks for adding the RELEASE.md file!

Here's a preview of the changelog:


This release fixes how we check for multipart subscriptions to be
in line with the latest changes in the spec.

Here's the tweet text:

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

Get it here 👉 https://strawberry.rocks/release/(next)

@patrick91
Copy link
Member Author

/pre-release

@botberry
Copy link
Member

Pre-release

👋

Releasing commit [d235ddd] to PyPi as pre-release! 📦

@botberry
Copy link
Member

Pre-release

👋

Pre-release 0.240.3.dev.1726159932 [d235ddd] has been released on PyPi! 🚀
You can try it by doing:

poetry add strawberry-graphql==0.240.3.dev.1726159932

Copy link

codecov bot commented Sep 12, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.75%. Comparing base (eb4f558) to head (d235ddd).
Report is 5 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3627      +/-   ##
==========================================
- Coverage   96.75%   96.75%   -0.01%     
==========================================
  Files         521      521              
  Lines       33715    33714       -1     
  Branches     5622     5622              
==========================================
- Hits        32622    32620       -2     
- Misses        861      863       +2     
+ Partials      232      231       -1     

Copy link

codspeed-hq bot commented Sep 12, 2024

CodSpeed Performance Report

Merging #3627 will not alter performance

Comparing fix/multipart-accept (d235ddd) with main (eb4f558)

Summary

✅ 15 untouched benchmarks

@patrick91 patrick91 enabled auto-merge (squash) September 13, 2024 14:48
@patrick91 patrick91 merged commit 7f84ed4 into main Sep 13, 2024
121 checks passed
@patrick91 patrick91 deleted the fix/multipart-accept branch September 13, 2024 14:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants