Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions src/GraphQL.Client/Websocket/GraphQLHttpWebSocket.cs
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ public IObservable<GraphQLResponse<TResponse>> CreateSubscriptionStream<TRespons
var typedResponse =
_client.JsonSerializer.DeserializeToWebsocketResponse<TResponse>(
response.MessageBytes);
Debug.WriteLine($"payload => {System.Text.Encoding.UTF8.GetString(response.MessageBytes)}");
o.OnNext(typedResponse.Payload);

// in case of a GraphQL error, terminate the sequence after the response has been posted
Expand Down Expand Up @@ -194,7 +195,7 @@ public IObservable<GraphQLResponse<TResponse>> CreateSubscriptionStream<TRespons
}
catch (Exception e)
{
Console.WriteLine(e);
Debug.WriteLine(e);
throw;
}

Expand All @@ -206,7 +207,7 @@ public IObservable<GraphQLResponse<TResponse>> CreateSubscriptionStream<TRespons
}
catch (Exception e)
{
Console.WriteLine(e);
Debug.WriteLine(e);
throw;
}

Expand Down Expand Up @@ -255,14 +256,18 @@ public IObservable<GraphQLResponse<TResponse>> CreateSubscriptionStream<TRespons
// unwrap and push results or throw wrapped exceptions
.SelectMany(t =>
{
Debug.WriteLine($"unwrap exception thread id: {Thread.CurrentThread.ManagedThreadId}");
// if the result contains an exception, throw it on the observable
if (t.Item2 != null)
{
Debug.WriteLine($"unwrap exception thread id: {Thread.CurrentThread.ManagedThreadId} => {t.Item2}");
return Observable.Throw<GraphQLResponse<TResponse>>(t.Item2);

return t.Item1 == null
? Observable.Empty<GraphQLResponse<TResponse>>()
: Observable.Return(t.Item1);
}
if (t.Item1 == null)
{
Debug.WriteLine($"empty item thread id: {Thread.CurrentThread.ManagedThreadId}");
return Observable.Empty<GraphQLResponse<TResponse>>();
}
return Observable.Return(t.Item1);
})
// transform to hot observable and auto-connect
.Publish().RefCount();
Expand Down Expand Up @@ -319,7 +324,7 @@ public Task<GraphQLResponse<TResponse>> SendRequest<TResponse>(GraphQLRequest re
}
catch (Exception e)
{
Console.WriteLine(e);
Debug.WriteLine(e);
throw;
}

Expand Down