Skip to content

Commit aa38225

Browse files
authored
Merge pull request #290 from bjorg/replace-console-writeline-statements
Debug logging for received payloads
2 parents 7fc83ae + 0dcc995 commit aa38225

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

src/GraphQL.Client/Websocket/GraphQLHttpWebSocket.cs

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ public IObservable<GraphQLResponse<TResponse>> CreateSubscriptionStream<TRespons
136136
var typedResponse =
137137
_client.JsonSerializer.DeserializeToWebsocketResponse<TResponse>(
138138
response.MessageBytes);
139+
Debug.WriteLine($"payload => {System.Text.Encoding.UTF8.GetString(response.MessageBytes)}");
139140
o.OnNext(typedResponse.Payload);
140141

141142
// in case of a GraphQL error, terminate the sequence after the response has been posted
@@ -194,7 +195,7 @@ public IObservable<GraphQLResponse<TResponse>> CreateSubscriptionStream<TRespons
194195
}
195196
catch (Exception e)
196197
{
197-
Console.WriteLine(e);
198+
Debug.WriteLine(e);
198199
throw;
199200
}
200201

@@ -206,7 +207,7 @@ public IObservable<GraphQLResponse<TResponse>> CreateSubscriptionStream<TRespons
206207
}
207208
catch (Exception e)
208209
{
209-
Console.WriteLine(e);
210+
Debug.WriteLine(e);
210211
throw;
211212
}
212213

@@ -255,14 +256,18 @@ public IObservable<GraphQLResponse<TResponse>> CreateSubscriptionStream<TRespons
255256
// unwrap and push results or throw wrapped exceptions
256257
.SelectMany(t =>
257258
{
258-
Debug.WriteLine($"unwrap exception thread id: {Thread.CurrentThread.ManagedThreadId}");
259259
// if the result contains an exception, throw it on the observable
260260
if (t.Item2 != null)
261+
{
262+
Debug.WriteLine($"unwrap exception thread id: {Thread.CurrentThread.ManagedThreadId} => {t.Item2}");
261263
return Observable.Throw<GraphQLResponse<TResponse>>(t.Item2);
262-
263-
return t.Item1 == null
264-
? Observable.Empty<GraphQLResponse<TResponse>>()
265-
: Observable.Return(t.Item1);
264+
}
265+
if (t.Item1 == null)
266+
{
267+
Debug.WriteLine($"empty item thread id: {Thread.CurrentThread.ManagedThreadId}");
268+
return Observable.Empty<GraphQLResponse<TResponse>>();
269+
}
270+
return Observable.Return(t.Item1);
266271
})
267272
// transform to hot observable and auto-connect
268273
.Publish().RefCount();
@@ -319,7 +324,7 @@ public Task<GraphQLResponse<TResponse>> SendRequest<TResponse>(GraphQLRequest re
319324
}
320325
catch (Exception e)
321326
{
322-
Console.WriteLine(e);
327+
Debug.WriteLine(e);
323328
throw;
324329
}
325330

0 commit comments

Comments
 (0)