machinebox / graphql

Simple low-level GraphQL HTTP client for Go
https://blog.machinebox.io/a-graphql-client-library-for-go-5bffd0455878
Apache License 2.0
933 stars 217 forks source link

Subscription support #54

Open klemens-morgenstern opened 4 years ago

klemens-morgenstern commented 4 years ago

I added subscription support, minimally tests against an apollo server.

I plan to write a graphql-code-gen plugin later on and will test more then, but I could use a small code review before that.

klemens-morgenstern commented 4 years ago

Any ideas how to test that in a more thorough way in the unit tests?

cusspvz commented 4 years ago

I'm not a maintainer on this project, but based on what I saw, we would need to ensure at least these two functionalities:

  1. handle responses from different subscriptions on the same subscription client (WebSocket)
  2. a main cancelable context + a reconnect system 2.1. the main cancelable context would allow us to cancel a client, independently of which WebSocket request we have on going (actually, the subscriptions-transport-ws had issues with this for a long time, and it is easier to deal with it recurring to go contexts. 2.2. the reconnect procedure would allow we would reconnect it until the main context gets canceled