hasura / go-graphql-client

Package graphql provides a GraphQL client implementation.
MIT License
395 stars 91 forks source link

feat: add sync mode for subscription events #114

Closed hgiasac closed 9 months ago

hgiasac commented 9 months ago

close https://github.com/hasura/go-graphql-client/issues/113

Add a new syncMode option to allow subscriptions to execute messages in sequence (without goroutine)

client.WithSyncMode(true)
hgiasac commented 9 months ago

I haven't tested in-depth about extremely high race condition use cases. However, there would be some locks on the read-message loop. For example, if the execution is too long, other messages will be locked or discarded from the WebSocket client.
So we should keep the async mode to avoid breaking changes for other users. It would be great if you could test and prove the sync mode works without issue. Thanks

andrexus commented 9 months ago

I have heavily tested this version in my project, which has numerous subscriptions, and I have not encountered any issues. I think it can be merged.