1010
1111namespace Linq2GraphQL . Generator
1212{
13- public class ClientGenerator
13+ public class ClientGenerator ( string namespaceName , string clientName , bool includeSubscriptions ,
14+ EnumGeneratorStrategy enumGeneratorStrategy , bool nullable , bool includeDeprecated )
1415 {
15- private readonly string namespaceName ;
16- private readonly string clientName ;
17- private readonly bool includeSubscriptions ;
18- private readonly EnumGeneratorStrategy enumGeneratorStrategy ;
19- private readonly bool nullable ;
2016 private readonly List < FileEntry > entries = new ( ) ;
2117
22- public ClientGenerator ( string namespaceName , string clientName , bool includeSubscriptions ,
23- EnumGeneratorStrategy enumGeneratorStrategy , bool nullable )
24- {
25- this . namespaceName = namespaceName ;
26- this . clientName = clientName ;
27- this . includeSubscriptions = includeSubscriptions ;
28- this . enumGeneratorStrategy = enumGeneratorStrategy ;
29- this . nullable = nullable ;
30- }
31-
3218 private void AddFile ( string directory , string fileName , string content )
3319 {
3420 var infoText = $@ "//---------------------------------------------------------------------
@@ -55,7 +41,18 @@ public async Task<List<FileEntry>> GenerateAsync(Uri uri, string authToken = nul
5541 }
5642
5743 httpClient . DefaultRequestHeaders . UserAgent . Add ( new ProductInfoHeaderValue ( "Linq2GraphQL" , "1.0" ) ) ;
58- using var response = await httpClient . PostAsJsonAsync ( uri , new { query = General . IntrospectionQuery } ) ;
44+
45+ string query = "" ;
46+ if ( includeDeprecated )
47+ {
48+ query = General . IntrospectionQueryIncludeDeprecated ;
49+ }
50+ else
51+ {
52+ query = General . IntrospectionQuery ;
53+ }
54+
55+ using var response = await httpClient . PostAsJsonAsync ( uri , new { query = query } ) ;
5956 if ( ! response . IsSuccessStatusCode )
6057 {
6158 throw new Exception (
@@ -72,7 +69,7 @@ public List<FileEntry> Generate(string schemaJson)
7269 {
7370 entries . Clear ( ) ;
7471
75- GeneratorSettings . Current = new GeneratorSettings { Nullable = this . nullable } ;
72+ GeneratorSettings . Current = new GeneratorSettings { Nullable = nullable } ;
7673
7774 var rootSchema = JsonSerializer . Deserialize < RootSchema > ( schemaJson ,
7875 new JsonSerializerOptions { PropertyNamingPolicy = JsonNamingPolicy . CamelCase } ) ;
@@ -175,7 +172,7 @@ public List<FileEntry> Generate(string schemaJson)
175172
176173
177174 Console . WriteLine ( "Generate Client..." ) ;
178- var templateText = new ClientTemplate ( namespaceName , clientName , queryType , mutationType , subscriptionType )
175+ var templateText = new ClientTemplate ( namespaceName , clientName , queryType , mutationType , subscriptionType , includeDeprecated )
179176 . TransformText ( ) ;
180177 var fileName = clientName + ".cs" ;
181178 AddFile ( clientDirName , fileName , templateText ) ;
0 commit comments