strawberry icon indicating copy to clipboard operation
strawberry copied to clipboard

Add support for multipart subscriptions

Open patrick91 opened this issue 2 years ago • 10 comments

This is a new protocol created by Apollo (and supported by Apollo Client)

TODO

  • [x] Add support for this in all HTTP integrations that support subscriptions
  • [x] Send a ping every 5 seconds (an empty {} is enough)
  • [x] Add a proper way to check if an operation is a subscription in our Async HTTP View
  • [x] Make sure that the returned responses is actually being streamed
  • [x] Return proper error when trying to run a subscription and it's not supported
  • [x] Add docs (using a proxy breaks the disconnection)

Protocol docs: https://www.apollographql.com/docs/router/executing-operations/subscription-multipart-protocol/

patrick91 avatar Sep 06 '23 10:09 patrick91

Codecov Report

Merging #3076 (4f5f1c4) into main (364d152) will increase coverage by 1.05%. The diff coverage is 95.91%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3076      +/-   ##
==========================================
+ Coverage   95.35%   96.40%   +1.05%     
==========================================
  Files         498      501       +3     
  Lines       31131    31337     +206     
  Branches     3809     3854      +45     
==========================================
+ Hits        29685    30211     +526     
+ Misses       1237      920     -317     
+ Partials      209      206       -3     

codecov[bot] avatar Sep 06 '23 10:09 codecov[bot]

CodSpeed Performance Report

Merging #3076 will not alter performance

Comparing feature/multipart (4f5f1c4) with main (364d152)

Summary

✅ 12 untouched benchmarks

codspeed-hq[bot] avatar Sep 06 '23 11:09 codspeed-hq[bot]

Hi 👋 You can find a preview of the docs here:

https://strawberry.rocks/docs/pr/3076/integrations/index

github-actions[bot] avatar Oct 15 '23 09:10 github-actions[bot]

~~one thing I'm not sure about this is handling client closing the connections 🤔 ~~

edit: this seems to be handled by fastapi, I need to check django and others, also I was using next.js' proxy for this, and that was preventing the disconnect message from being sent

patrick91 avatar Oct 15 '23 09:10 patrick91

/pre-release

patrick91 avatar Oct 20 '23 10:10 patrick91

Pre-release

:wave:

Pre-release 0.218.0.dev.1705418681 [48e52e93fff32060fe0be650244907fd3f6ff6cb] has been released on PyPi! :rocket: You can try it by doing:

poetry add strawberry-graphql==0.218.0.dev.1705418681

botberry avatar Oct 20 '23 10:10 botberry

/pre-release

patrick91 avatar Nov 08 '23 11:11 patrick91

/pre-release

patrick91 avatar Jan 16 '24 15:01 patrick91

Apollo Federation Subgraph Compatibility Results

Federation 1 SupportFederation 2 Support
_service🟢
@key (single)🟢
@key (multi)🟢
@key (composite)🟢
repeatable @key🟢
@requires🟢
@provides🟢
federated tracing🔲
@link🟢
@shareable🟢
@tag🟢
@override🟢
@inaccessible🟢
@composeDirective🟢
@interfaceObject🟢

Learn more:

botberry avatar Jan 24 '24 14:01 botberry

Thanks for adding the RELEASE.md file!

Here's a preview of the changelog:


This release adds support for multipart subscriptions in almost all* integrations!

Multipart subcriptions are a new protocol from Apollo GraphQL, built on the Incremental Delivery over HTTP spec, which is also used for @defer and @stream.

The main advantage of this protocol is that when using the Apollo Client libraries you don't need to install any additional dependency, but in future this feature will make it easier for us to implement @defer and @stream

Also, this means that you don't need to use Django Channels for subscription, since this protocol is based on HTTP we don't need to use websockets.

  • Flask, Chalice and the sync Django integration don't support this yet.

Here's the tweet text:

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

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

botberry avatar Jan 24 '24 14:01 botberry