gql icon indicating copy to clipboard operation
gql copied to clipboard

Add HTTP multipart transport for GraphQL subscriptions

Open magicmark opened this issue 1 month ago • 7 comments

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

magicmark avatar Nov 12 '25 20:11 magicmark

cc @patrick91 ;)

magicmark avatar Nov 12 '25 20:11 magicmark

Thanks for your work on this!

So do you know if there is a public backend somewhere supporting this protocol?

leszekhanusz avatar Nov 12 '25 21:11 leszekhanusz

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

magicmark avatar Nov 12 '25 21:11 magicmark

not that i know of - but i'll start doing that now, i can throw something up on a lambda worker

Great!

leszekhanusz avatar Nov 12 '25 21:11 leszekhanusz

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.

codecov[bot] avatar Nov 12 '25 21:11 codecov[bot]

For the linting issues, you should run make check to fix the code. See CONTRIBUTING.md

leszekhanusz avatar Nov 12 '25 21:11 leszekhanusz

@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)

magicmark avatar Nov 13 '25 03:11 magicmark

@leszekhanusz ready for review!

magicmark avatar Dec 20 '25 00:12 magicmark

@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 avatar Dec 20 '25 17:12 leszekhanusz

@leszekhanusz apologies the github actions were stuck for a while so i didn't see the failing stuff. will take a look.

magicmark avatar Dec 20 '25 22:12 magicmark