-
Notifications
You must be signed in to change notification settings - Fork 136
Subscriptions API #92
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
deinok
merged 55 commits into
graphql-dotnet:subscriptions-api
from
haprotec:subscriptions-api
Jan 29, 2019
Merged
Subscriptions API #92
deinok
merged 55 commits into
graphql-dotnet:subscriptions-api
from
haprotec:subscriptions-api
Jan 29, 2019
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
* nonnullable * fix some things * other fix * netstandard2.0
…-client into subscriptions-api
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Improvements to the Subscription API (#25)
Single websocket per client
There is only a single websocket connection established per client. This connection is shared across all subscriptions and optionally requests.
Requests via websocket
By setting
GraphQLHttpClientOptions.UseWebSocketForQueriesAndMutations = trueyou can force requests and mutations to use the websocket too, which can reduce the connection overhead on regular requests.Re-establish subscriptions on connection loss
If the receiving pipeline of the WebSocket encounters a WebSocketException, the client tries to re-establish the connection and on success re-initiates all current subscriptions to the server.
Since this prevents all WebsocketExceptions from reaching the Observer, all exceptions occurring in the receiving pipeline are submitted to the
GraphQLHttpClient.WebSocketReceiveErrorsobservable (i.e. for logging purposes.This behaviour can be overridden per subscription by using the
GraphQLHttpClient.CreateSubscriptionStream(GraphQLRequest request, Action<Exception> exceptionHandler)overload and re-throwing the exception inside the exceptionHandlerReuse subscriptions for identical requests
The created observables for subscriptions are cached in
GraphQLHttpClient. If a second subscription is made with the identical request, the existing observable is returned (instead of creating a second subscription to the server)Receive long response messages from the WebSocket
The receiving loop now keeps reading into a smaller buffer until
WebSocketReceiveResult.EndOfMessagebecomestrue.Windows 7 compatibility
The usage of
ClientWebSocketthrows aPlatformNotSupportedExceptionon Windows 7 (since Microsoft did not implement it there).This is fixed by using https://github.com/PingmanTools/System.Net.WebSockets.Client.Managed