@@ -23,6 +23,18 @@ public class GeneratorOptions
2323 public bool NoGeneratedTimestamp { get ; set ; }
2424 public bool ConvertToUnixLineEnding { get ; set ; } = true ;
2525 }
26+
27+ public class ModelType
28+ {
29+ public string Namespace { get ; set ; }
30+ public string SchemaFile { get ; set ; }
31+ public Dictionary < string , TypeInfo > Types { get ; set ; }
32+ public Dictionary < string , List < EnumInfo > > Enums { get ; set ; }
33+ public TypeInfo Mutation { get ; set ; }
34+ public string CmdArgs { get ; set ; }
35+ public string Usings { get ; set ; }
36+ public bool NoGeneratedTimestamp { get ; set ; }
37+ }
2638
2739 public static class Generator
2840 {
@@ -101,7 +113,7 @@ public static async Task Generate(GeneratorOptions options)
101113
102114 var allTypes = typeInfo . Types . Concat ( typeInfo . Inputs ) . ToDictionary ( k => k . Key , v => v . Value ) ;
103115
104- string resultTypes = await engine . CompileRenderAsync ( "resultTypes.cshtml" , new
116+ string resultTypes = await engine . CompileRenderAsync ( "resultTypes.cshtml" , new ModelType
105117 {
106118 Namespace = options . Namespace ,
107119 SchemaFile = options . Source ,
@@ -110,20 +122,20 @@ public static async Task Generate(GeneratorOptions options)
110122 Mutation = typeInfo . Mutation ,
111123 CmdArgs = $ "-n { options . Namespace } -c { options . ClientClassName } -m { options . ScalarMapping } -u { options . Usings . Replace ( "\n " , "\\ n" ) } ",
112124 Usings = options . Usings ,
113- options . NoGeneratedTimestamp
125+ NoGeneratedTimestamp = options . NoGeneratedTimestamp
114126 } ) ;
115127 Directory . CreateDirectory ( options . OutputDir ) ;
116128 await NormalizeAndWriteIfChanged ( $ "{ options . OutputDir } /GeneratedResultTypes.cs", resultTypes , options . ConvertToUnixLineEnding ) ;
117129
118- string queryTypes = await engine . CompileRenderAsync ( "queryTypes.cshtml" , new
130+ string queryTypes = await engine . CompileRenderAsync ( "queryTypes.cshtml" , new ModelType
119131 {
120132 Namespace = options . Namespace ,
121133 SchemaFile = options . Source ,
122134 Types = allTypes ,
123135 Mutation = typeInfo . Mutation ,
124136 CmdArgs = $ "-n { options . Namespace } -c { options . ClientClassName } -m { options . ScalarMapping } -u { options . Usings . Replace ( "\n " , "\\ n" ) } ",
125137 Usings = options . Usings ,
126- options . NoGeneratedTimestamp
138+ NoGeneratedTimestamp = options . NoGeneratedTimestamp
127139 } ) ;
128140 Directory . CreateDirectory ( options . OutputDir ) ;
129141 await NormalizeAndWriteIfChanged ( $ "{ options . OutputDir } /GeneratedQueryTypes.cs", queryTypes , options . ConvertToUnixLineEnding ) ;
0 commit comments