Skip to content

Commit 059ea37

Browse files
committed
Refactor GraphClient constructor to add an overload for optional includeDeprecated parameter. Clean up whitespace in GraphClient and ClientGenerator files for improved readability. Update project file to enable TransformOnBuild to avoid forgetting to do that.
1 parent 035c296 commit 059ea37

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

src/Linq2GraphQL.Client/GraphClient.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using System.Text.Json;
22
using System.Text.Json.Serialization;
3-
using Linq2GraphQL.Client.Converters;
43
using Linq2GraphQL.Client.Schema;
54
using Microsoft.Extensions.Caching.Memory;
65
using Microsoft.Extensions.DependencyInjection;
@@ -14,6 +13,11 @@ public class GraphClient
1413
private readonly IOptions<GraphClientOptions> options;
1514
private readonly bool includeDeprecated;
1615

16+
public GraphClient(HttpClient httpClient, IOptions<GraphClientOptions> options, IServiceProvider provider)
17+
: this(httpClient, options, provider, false)
18+
{
19+
}
20+
1721
public GraphClient(HttpClient httpClient, IOptions<GraphClientOptions> options, IServiceProvider provider, bool includeDeprecated = false)
1822
{
1923
this.options = options;
@@ -38,7 +42,7 @@ public GraphClient(HttpClient httpClient, IOptions<GraphClientOptions> options,
3842
public SubscriptionProtocol SubscriptionProtocol => options.Value.SubscriptionProtocol;
3943
public HttpClient HttpClient { get; }
4044
public JsonSerializerOptions SerializerOptions { get; }
41-
45+
4246

4347
public Func<GraphClient, Task<GraphQLRequest>> WSConnectionInitPayload => options.Value.WSConnectionInitPayload;
4448
private string GetSubscriptionUrl()
@@ -85,7 +89,7 @@ public async Task<GraphQLSchema> GetSchemaForSafeModeAsync()
8589
query = Helpers.SchemaQuery;
8690
}
8791

88-
var graphRequest = new GraphQLRequest { Query = query };
92+
var graphRequest = new GraphQLRequest { Query = query };
8993
return await executor.ExecuteRequestAsync("__schema", graphRequest);
9094
});
9195
}

src/Linq2GraphQL.Generator/ClientGenerator.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public async Task<List<FileEntry>> GenerateAsync(Uri uri, string authToken = nul
5252
query = General.IntrospectionQuery;
5353
}
5454

55-
using var response = await httpClient.PostAsJsonAsync(uri, new { query = query });
55+
using var response = await httpClient.PostAsJsonAsync(uri, new { query = query });
5656
if (!response.IsSuccessStatusCode)
5757
{
5858
throw new Exception(
@@ -106,7 +106,7 @@ public List<FileEntry> Generate(string schemaJson)
106106

107107
var classInterfacesList = schema.GetClassTypes()?.Where(e => e.HasInterfaces)
108108
?.SelectMany(i => i.Interfaces?.ToDictionary(e => i.Name, e => e.Name))?.ToList() ?? new List<KeyValuePair<string, string>>();
109-
109+
110110
var interfaces = schema.GetInterfaces();
111111
if (interfaces != null)
112112
{

src/Linq2GraphQL.Generator/Linq2GraphQL.Generator.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
<ImplicitUsings>enable</ImplicitUsings>
77
<PackAsTool>true</PackAsTool>
88
<ToolCommandName>Linq2GraphQL</ToolCommandName>
9+
<TransformOnBuild>true</TransformOnBuild>
910

1011
<Authors>Joakim Dangården, Magnus Ahlberg</Authors>
1112
<Company>Linq2GraphQL</Company>

0 commit comments

Comments
 (0)