Skip to content
Merged
Show file tree
Hide file tree
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
7 changes: 4 additions & 3 deletions src/GraphQL.Client/Http/GraphQLHttpClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,14 @@ public GraphQLHttpClient(GraphQLHttpClientOptions options) {
this.graphQLHttpHandler = new GraphQLHttpHandler(options);
}

internal GraphQLHttpClient(GraphQLHttpClientOptions options,HttpClient httpClient) {
internal GraphQLHttpClient(GraphQLHttpClientOptions options, HttpClient httpClient) {
if (options == null) { throw new ArgumentNullException(nameof(options)); }
if (options.EndPoint == null) { throw new ArgumentNullException(nameof(options.EndPoint)); }
if (options.JsonSerializerSettings == null) { throw new ArgumentNullException(nameof(options.JsonSerializerSettings)); }
if (options.HttpMessageHandler == null) { throw new ArgumentNullException(nameof(options.HttpMessageHandler)); }
if (options.MediaType == null) { throw new ArgumentNullException(nameof(options.MediaType)); }

this.graphQLHttpHandler = new GraphQLHttpHandler(options,httpClient);
this.graphQLHttpHandler = new GraphQLHttpHandler(options, httpClient);
}

public Task<GraphQLResponse> SendQueryAsync(string query, CancellationToken cancellationToken = default) =>
Expand All @@ -121,7 +121,8 @@ public Task<IGraphQLSubscriptionResult> SendSubscribeAsync(GraphQLRequest reques
if (request == null) { throw new ArgumentNullException(nameof(request)); }
if (request.Query == null) { throw new ArgumentNullException(nameof(request.Query)); }

var webSocketUri = new Uri($"ws://{this.EndPoint.Host}:{this.EndPoint.Port}{this.EndPoint.AbsolutePath}");
var webSocketSchema = this.EndPoint.Scheme == "https" ? "wss" : "ws";
var webSocketUri = new Uri($"{webSocketSchema}://{this.EndPoint.Host}:{this.EndPoint.Port}{this.EndPoint.AbsolutePath}");
var graphQLSubscriptionResult = new GraphQLHttpSubscriptionResult(webSocketUri, request);
graphQLSubscriptionResult.StartAsync(cancellationToken);
return Task.FromResult((IGraphQLSubscriptionResult)graphQLSubscriptionResult);
Expand Down
2 changes: 2 additions & 0 deletions src/GraphQL.Client/Http/GraphQLHttpSubscriptionResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ private Task SendInitialMessageAsync(CancellationToken cancellationToken = defau
}

private static class GQLWebSocketMessageType {

/// <summary>
/// Client sends this message after plain websocket connection to start the communication with the server
/// The server will response only with GQL_CONNECTION_ACK + GQL_CONNECTION_KEEP_ALIVE(if used) or GQL_CONNECTION_ERROR
Expand Down Expand Up @@ -142,6 +143,7 @@ private static class GQLWebSocketMessageType {
/// id: string : operation id
/// </summary>
public const string GQL_STOP = "stop"; // Client -> Server

}

}
Expand Down
3 changes: 2 additions & 1 deletion src/GraphQL.Client/Http/Internal/GraphQLHttpHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ public async Task<GraphQLResponse> ReadHttpResponseMessageAsync(HttpResponseMess
};
try {
return jsonSerializer.Deserialize<GraphQLResponse>(jsonTextReader);
} catch (JsonReaderException exception) {
}
catch (JsonReaderException exception) {
if (httpResponseMessage.IsSuccessStatusCode) {
throw exception;
}
Expand Down
2 changes: 1 addition & 1 deletion src/GraphQL.Client/Obsolete.GraphQLClient.Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace GraphQL.Client {
/// <summary>
/// Extension Methods for <see cref="GraphQLClient"/>
/// </summary>
[Obsolete()]
[Obsolete]
public static class GraphQLClientExtensions {

private const string IntrospectionQuery = @"
Expand Down