Add HTTP multipart transport for GraphQL subscriptions
Fix https://github.com/graphql-python/gql/issues/463
(This PR is 95% authored by claude. I have manually verified against a locally running server. Code looks good? I'll keep reviewing too before removing the draft marker since I don't just wanna dump a bunch of slop on you.)
Implements the multipart subscription protocol for receiving streaming subscription updates over HTTP as an alternative to WebSocket transports. This protocol is implemented by Apollo GraphOS Router and other compatible servers, and is particularly useful when WebSocket connections are not available or blocked by infrastructure.
The transport handles multipart/mixed responses with heartbeat support and proper error handling for both GraphQL and transport-level errors. It requires servers to support the multipart subscription protocol - requests that don't receive a multipart response will fail with a clear error message.
🤖 Generated with Claude Code
cc @patrick91 ;)
Thanks for your work on this!
So do you know if there is a public backend somewhere supporting this protocol?
So do you know if there is a public backend somewhere supporting this protocol?
not that i know of - but i'll start doing that now, i can throw something up on a lambda worker
not that i know of - but i'll start doing that now, i can throw something up on a lambda worker
Great!
Codecov Report
:x: Patch coverage is 98.37398% with 2 lines in your changes missing coverage. Please review.
:white_check_mark: Project coverage is 99.94%. Comparing base (7fb869a) to head (4612259).
:warning: Report is 45 commits behind head on master.
| Files with missing lines | Patch % | Lines |
|---|---|---|
| gql/transport/http_multipart_transport.py | 98.37% | 2 Missing :warning: |
Additional details and impacted files
@@ Coverage Diff @@
## master #574 +/- ##
===========================================
- Coverage 100.00% 99.94% -0.06%
===========================================
Files 38 41 +3
Lines 2908 3363 +455
===========================================
+ Hits 2908 3361 +453
- Misses 0 2 +2
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
:rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
For the linting issues, you should run make check to fix the code. See CONTRIBUTING.md
@leszekhanusz https://github.com/magicmark/gql-book-server/ :)
publicly accessible here here: https://gql-book-server.fly.dev/graphql
(I was too dumb to get multipart + chunked transfer encoding working via a lambda so just deploying on the cheapest fly.io machine possible)
@leszekhanusz ready for review!
@magicmark Thanks for the work and the backend. Do you want me to push it over the finish line by fixing the few remaining issues?
@leszekhanusz apologies the github actions were stuck for a while so i didn't see the failing stuff. will take a look.