Skip to content
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

Remove forced camel casing #58

Closed
wants to merge 1 commit into from
Closed
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
14 changes: 7 additions & 7 deletions src/GraphQL.Client/Http/GraphQLHttpClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,26 +100,26 @@ public partial class GraphQLHttpClient : IGraphQLClient {
this.graphQLHttpHandler = new GraphQLHttpHandler(options,httpClient);
}

public async Task<GraphQLResponse> SendQueryAsync(string query, CancellationToken cancellationToken = default) =>
await this.SendQueryAsync(new GraphQLRequest { Query = query }, cancellationToken).ConfigureAwait(false);
public async Task<GraphQLResponse> SendQueryAsync(string _query, CancellationToken cancellationToken = default) =>
await this.SendQueryAsync(new GraphQLRequest { query = _query }, cancellationToken).ConfigureAwait(false);

public async Task<GraphQLResponse> SendQueryAsync(GraphQLRequest request, CancellationToken cancellationToken = default) =>
await this.graphQLHttpHandler.PostAsync(request, cancellationToken).ConfigureAwait(false);

public async Task<GraphQLResponse> SendMutationAsync(string query, CancellationToken cancellationToken = default) =>
await this.SendMutationAsync(new GraphQLRequest { Query = query }, cancellationToken).ConfigureAwait(false);
public async Task<GraphQLResponse> SendMutationAsync(string _query, CancellationToken cancellationToken = default) =>
await this.SendMutationAsync(new GraphQLRequest { query = _query }, cancellationToken).ConfigureAwait(false);

public async Task<GraphQLResponse> SendMutationAsync(GraphQLRequest request, CancellationToken cancellationToken = default) =>
await this.graphQLHttpHandler.PostAsync(request, cancellationToken).ConfigureAwait(false);

[Obsolete("EXPERIMENTAL API")]
public async Task<IGraphQLSubscriptionResult> SendSubscribeAsync(string query, CancellationToken cancellationToken = default) =>
await this.SendSubscribeAsync(new GraphQLRequest { Query = query }, cancellationToken).ConfigureAwait(false);
public async Task<IGraphQLSubscriptionResult> SendSubscribeAsync(string _query, CancellationToken cancellationToken = default) =>
await this.SendSubscribeAsync(new GraphQLRequest { query = _query }, cancellationToken).ConfigureAwait(false);

[Obsolete("EXPERIMENTAL API")]
public async Task<IGraphQLSubscriptionResult> SendSubscribeAsync(GraphQLRequest request, CancellationToken cancellationToken = default) {
if (request == null) { throw new ArgumentNullException(nameof(request)); }
if (request.Query == null) { throw new ArgumentNullException(nameof(request.Query)); }
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 graphQLSubscriptionResult = new GraphQLHttpSubscriptionResult(webSocketUri, request);
Expand Down
1 change: 0 additions & 1 deletion src/GraphQL.Client/Http/GraphQLHttpClientOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ public class GraphQLHttpClientOptions {
/// The <see cref="Newtonsoft.Json.JsonSerializerSettings"/> that is going to be used
/// </summary>
public JsonSerializerSettings JsonSerializerSettings { get; set; } = new JsonSerializerSettings {
ContractResolver = new CamelCasePropertyNamesContractResolver()
};

/// <summary>
Expand Down
10 changes: 5 additions & 5 deletions src/GraphQL.Client/Http/Internal/GraphQLHttpHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ internal class GraphQLHttpHandler : IDisposable {
/// <returns>The Response</returns>
public async Task<GraphQLResponse> GetAsync(GraphQLRequest request, CancellationToken cancellationToken = default) {
if (request == null) { throw new ArgumentNullException(nameof(request)); }
if (request.Query == null) { throw new ArgumentNullException(nameof(request.Query)); }
if (request.query == null) { throw new ArgumentNullException(nameof(request.query)); }

var queryParamsBuilder = new StringBuilder($"query={request.Query}", 3);
if (request.OperationName != null) { queryParamsBuilder.Append($"&operationName={request.OperationName}"); }
if (request.Variables != null) { queryParamsBuilder.Append($"&variables={JsonConvert.SerializeObject(request.Variables)}"); }
var queryParamsBuilder = new StringBuilder($"query={request.query}", 3);
if (request.operationName != null) { queryParamsBuilder.Append($"&operationName={request.operationName}"); }
if (request.variables != null) { queryParamsBuilder.Append($"&variables={JsonConvert.SerializeObject(request.variables)}"); }
using (var httpResponseMessage = await this.HttpClient.GetAsync($"{this.Options.EndPoint}?{queryParamsBuilder.ToString()}", cancellationToken).ConfigureAwait(false)) {
return await this.ReadHttpResponseMessageAsync(httpResponseMessage).ConfigureAwait(false);
}
Expand All @@ -62,7 +62,7 @@ internal class GraphQLHttpHandler : IDisposable {
/// <returns>The Response</returns>
public async Task<GraphQLResponse> PostAsync(GraphQLRequest request, CancellationToken cancellationToken = default) {
if (request == null) { throw new ArgumentNullException(nameof(request)); }
if (request.Query == null) { throw new ArgumentNullException(nameof(request.Query)); }
if (request.query == null) { throw new ArgumentNullException(nameof(request.query)); }

var graphQLString = JsonConvert.SerializeObject(request, this.Options.JsonSerializerSettings);
using (var httpContent = new StringContent(graphQLString)) {
Expand Down
4 changes: 2 additions & 2 deletions src/GraphQL.Client/Obsolete.GraphQLClient.Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ public static class GraphQLClientExtensions {
}";

private static readonly GraphQLRequest IntrospectionGraphQLRequest = new GraphQLRequest {
Query = IntrospectionQuery.Replace("\t", "").Replace("\n", "").Replace("\r", ""),
Variables = null
query = IntrospectionQuery.Replace("\t", "").Replace("\n", "").Replace("\r", ""),
variables = null
};

/// <summary>
Expand Down
12 changes: 6 additions & 6 deletions src/GraphQL.Client/Obsolete.GraphQLClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ public class GraphQLClient : GraphQLHttpClient {
/// <summary>
/// Send a query via GET
/// </summary>
/// <param name="query">The Request</param>
/// <param name="_query">The Request</param>
/// <param name="cancellationToken">A cancellation token that can be used by other objects or threads to receive notice of cancellation.</param>
/// <returns>The Response</returns>
public async Task<GraphQLResponse> GetQueryAsync(string query, CancellationToken cancellationToken = default) =>
await this.GetAsync(new GraphQLRequest { Query = query }, cancellationToken).ConfigureAwait(false);
public async Task<GraphQLResponse> GetQueryAsync(string _query, CancellationToken cancellationToken = default) =>
await this.GetAsync(new GraphQLRequest { query = _query }, cancellationToken).ConfigureAwait(false);

/// <summary>
/// Send a <see cref="GraphQLRequest"/> via GET
Expand All @@ -67,11 +67,11 @@ public class GraphQLClient : GraphQLHttpClient {
/// <summary>
/// Send a query via POST
/// </summary>
/// <param name="query">The Request</param>
/// <param name="_query">The Request</param>
/// <param name="cancellationToken">A cancellation token that can be used by other objects or threads to receive notice of cancellation.</param>
/// <returns>The Response</returns>
public async Task<GraphQLResponse> PostQueryAsync(string query, CancellationToken cancellationToken = default) =>
await this.PostAsync(new GraphQLRequest { Query = query }, cancellationToken).ConfigureAwait(false);
public async Task<GraphQLResponse> PostQueryAsync(string _query, CancellationToken cancellationToken = default) =>
await this.PostAsync(new GraphQLRequest { query = _query }, cancellationToken).ConfigureAwait(false);

/// <summary>
/// Send a <see cref="GraphQLRequest"/> via POST
Expand Down
20 changes: 10 additions & 10 deletions src/GraphQL.Common/Request/GraphQLRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@ public class GraphQLRequest : IEquatable<GraphQLRequest> {
/// <summary>
/// The Query
/// </summary>
public string Query { get; set; }
public string query { get; set; }

/// <summary>
/// If the provided <see cref="Query"/> contains multiple named operations, this specifies which operation should be executed.
/// If the provided <see cref="query"/> contains multiple named operations, this specifies which operation should be executed.
/// </summary>
public string OperationName { get; set; }
public string operationName { get; set; }

/// <summary>
/// The Variables
/// </summary>
public dynamic Variables { get; set; }
public dynamic variables { get; set; }

/// <inheritdoc />
public override bool Equals(object obj) => this.Equals(obj as GraphQLRequest);
Expand All @@ -35,13 +35,13 @@ public class GraphQLRequest : IEquatable<GraphQLRequest> {
if (ReferenceEquals(this, other)) {
return true;
}
if (!Equals(this.Query, other.Query)) {
if (!Equals(this.query, other.query)) {
return false;
}
if (!Equals(this.OperationName, other.OperationName)) {
if (!Equals(this.operationName, other.operationName)) {
return false;
}
if (!Equals(this.Variables, other.Variables)) {
if (!Equals(this.variables, other.variables)) {
return false;
}
return true;
Expand All @@ -50,9 +50,9 @@ public class GraphQLRequest : IEquatable<GraphQLRequest> {
/// <inheritdoc />
public override int GetHashCode() {
var hashCode = -689803966;
hashCode = hashCode * -1521134295 + EqualityComparer<string>.Default.GetHashCode(this.Query);
hashCode = hashCode * -1521134295 + EqualityComparer<string>.Default.GetHashCode(this.OperationName);
hashCode = hashCode * -1521134295 + EqualityComparer<dynamic>.Default.GetHashCode(this.Variables);
hashCode = hashCode * -1521134295 + EqualityComparer<string>.Default.GetHashCode(this.query);
hashCode = hashCode * -1521134295 + EqualityComparer<string>.Default.GetHashCode(this.operationName);
hashCode = hashCode * -1521134295 + EqualityComparer<dynamic>.Default.GetHashCode(this.variables);
return hashCode;
}

Expand Down
16 changes: 8 additions & 8 deletions tests/GraphQL.Client.Tests/GraphQLClientGetTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public class GraphQLClientGetTests : BaseGraphQLClientTest {
[Fact]
public async void QueryGetAsyncFact() {
var graphQLRequest = new GraphQLRequest {
Query = @"
query = @"
{
person(personID: ""1"") {
name
Expand All @@ -25,7 +25,7 @@ public class GraphQLClientGetTests : BaseGraphQLClientTest {
[Fact]
public async void OperationNameGetAsyncFact() {
var graphQLRequest = new GraphQLRequest {
Query = @"
query = @"
query Person{
person(personID: ""1"") {
name
Expand All @@ -37,7 +37,7 @@ public class GraphQLClientGetTests : BaseGraphQLClientTest {
name
}
}",
OperationName = "Person"
operationName = "Person"
};
var response = await this.GraphQLClient.GetAsync(graphQLRequest).ConfigureAwait(false);

Expand All @@ -48,13 +48,13 @@ public class GraphQLClientGetTests : BaseGraphQLClientTest {
[Fact]
public async void VariablesGetAsyncFact() {
var graphQLRequest = new GraphQLRequest {
Query = @"
query = @"
query Person($personId: ID!){
person(personID: $personId) {
name
}
}",
Variables = new {
variables = new {
personId = "1"
}
};
Expand All @@ -67,7 +67,7 @@ public class GraphQLClientGetTests : BaseGraphQLClientTest {
[Fact]
public async void OperationNameVariableGetAsyncFact() {
var graphQLRequest = new GraphQLRequest {
Query = @"
query = @"
query Person($personId: ID!){
person(personID: $personId) {
name
Expand All @@ -79,8 +79,8 @@ public class GraphQLClientGetTests : BaseGraphQLClientTest {
name
}
}",
OperationName = "Person",
Variables = new {
operationName = "Person",
variables = new {
personId = "1"
}
};
Expand Down
18 changes: 9 additions & 9 deletions tests/GraphQL.Client.Tests/GraphQLClientPostTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class GraphQLClientPostTests : BaseGraphQLClientTest {
[Fact]
public async void QueryPostAsyncFact() {
var graphQLRequest = new GraphQLRequest {
Query = @"
query = @"
{
person(personID: ""1"") {
name
Expand All @@ -28,7 +28,7 @@ public async void QueryPostAsyncWithoutUtf8EncodingFact()
{
var graphQLRequest = new GraphQLRequest
{
Query = @"
query = @"
{
person(personID: ""1"") {
name
Expand All @@ -45,7 +45,7 @@ public async void QueryPostAsyncWithoutUtf8EncodingFact()
[Fact]
public async void OperationNamePostAsyncFact() {
var graphQLRequest = new GraphQLRequest {
Query = @"
query = @"
query Person{
person(personID: ""1"") {
name
Expand All @@ -57,7 +57,7 @@ public async void QueryPostAsyncWithoutUtf8EncodingFact()
name
}
}",
OperationName = "Person"
operationName = "Person"
};
var response = await this.GraphQLClient.PostAsync(graphQLRequest).ConfigureAwait(false);

Expand All @@ -68,13 +68,13 @@ public async void QueryPostAsyncWithoutUtf8EncodingFact()
[Fact]
public async void VariablesPostAsyncFact() {
var graphQLRequest = new GraphQLRequest {
Query = @"
query = @"
query Person($personId: ID!){
person(personID: $personId) {
name
}
}",
Variables = new {
variables = new {
personId = "1"
}
};
Expand All @@ -87,7 +87,7 @@ public async void QueryPostAsyncWithoutUtf8EncodingFact()
[Fact]
public async void OperationNameVariablePostAsyncFact() {
var graphQLRequest = new GraphQLRequest {
Query = @"
query = @"
query Person($personId: ID!){
person(personID: $personId) {
name
Expand All @@ -99,8 +99,8 @@ public async void QueryPostAsyncWithoutUtf8EncodingFact()
name
}
}",
OperationName = "Person",
Variables = new {
operationName = "Person",
variables = new {
personId = "1"
}
};
Expand Down
16 changes: 8 additions & 8 deletions tests/GraphQL.Client.Tests/Http/HttpClientExtensionsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class HttpClientExtensionsTest : BaseGraphQLClientTest {
[Fact]
public async void QueryGetAsyncFact() {
var graphQLRequest = new GraphQLRequest {
Query = @"
query = @"
{
person(personID: ""1"") {
name
Expand All @@ -30,7 +30,7 @@ public class HttpClientExtensionsTest : BaseGraphQLClientTest {
[Fact]
public async void OperationNameGetAsyncFact() {
var graphQLRequest = new GraphQLRequest {
Query = @"
query = @"
query Person{
person(personID: ""1"") {
name
Expand All @@ -42,7 +42,7 @@ public class HttpClientExtensionsTest : BaseGraphQLClientTest {
name
}
}",
OperationName = "Person"
operationName = "Person"
};
var response = await this.GraphQLHttpClient.SendQueryAsync(graphQLRequest).ConfigureAwait(false);

Expand All @@ -53,13 +53,13 @@ public class HttpClientExtensionsTest : BaseGraphQLClientTest {
[Fact]
public async void VariablesGetAsyncFact() {
var graphQLRequest = new GraphQLRequest {
Query = @"
query = @"
query Person($personId: ID!){
person(personID: $personId) {
name
}
}",
Variables = new {
variables = new {
personId = "1"
}
};
Expand All @@ -72,7 +72,7 @@ public class HttpClientExtensionsTest : BaseGraphQLClientTest {
[Fact]
public async void OperationNameVariableGetAsyncFact() {
var graphQLRequest = new GraphQLRequest {
Query = @"
query = @"
query Person($personId: ID!){
person(personID: $personId) {
name
Expand All @@ -84,8 +84,8 @@ public class HttpClientExtensionsTest : BaseGraphQLClientTest {
name
}
}",
OperationName = "Person",
Variables = new {
operationName = "Person",
variables = new {
personId = "1"
}
};
Expand Down
Loading