diff --git a/src/GraphQlClientGenerator/GraphQlGenerator.cs b/src/GraphQlClientGenerator/GraphQlGenerator.cs index a8c75ca..3c8e441 100644 --- a/src/GraphQlClientGenerator/GraphQlGenerator.cs +++ b/src/GraphQlClientGenerator/GraphQlGenerator.cs @@ -289,9 +289,9 @@ void WriteMappingEntry(string netType, string graphQlTypeName) typeMappingSeparator = ","; } - foreach (var type in graphQlTypes.Where(t => t.Kind is GraphQlTypeKind.Object or GraphQlTypeKind.InputObject)) + foreach (var type in graphQlTypes.Where(t => t.Kind is GraphQlTypeKind.Object or GraphQlTypeKind.InputObject or GraphQlTypeKind.Enum)) { - if (type.Kind == GraphQlTypeKind.InputObject) + if (type.Kind is GraphQlTypeKind.InputObject or GraphQlTypeKind.Enum) { var netType = $"{_configuration.ClassPrefix}{GetCSharpClassName(context, type.Name)}{_configuration.ClassSuffix}"; WriteMappingEntry(netType, type.Name); diff --git a/test/GraphQlClientGenerator.Test/ExpectedSingleFileGenerationContext/DataClasses b/test/GraphQlClientGenerator.Test/ExpectedSingleFileGenerationContext/DataClasses index 36a40be..4571629 100644 --- a/test/GraphQlClientGenerator.Test/ExpectedSingleFileGenerationContext/DataClasses +++ b/test/GraphQlClientGenerator.Test/ExpectedSingleFileGenerationContext/DataClasses @@ -37,6 +37,9 @@ public static class GraphQlTypes public static readonly IReadOnlyDictionary ReverseMapping = new Dictionary { + { typeof(Avatar), "Avatar" }, + { typeof(PriceLevel), "PriceLevel" }, + { typeof(Resolution), "Resolution" }, { typeof(bool), "Boolean" }, { typeof(DateTimeOffset), "String" }, { typeof(int), "Int" }, diff --git a/test/GraphQlClientGenerator.Test/ExpectedSingleFileGenerationContext/DataClassesWithTypeConfiguration b/test/GraphQlClientGenerator.Test/ExpectedSingleFileGenerationContext/DataClassesWithTypeConfiguration index df47a59..d5b4fd3 100644 --- a/test/GraphQlClientGenerator.Test/ExpectedSingleFileGenerationContext/DataClassesWithTypeConfiguration +++ b/test/GraphQlClientGenerator.Test/ExpectedSingleFileGenerationContext/DataClassesWithTypeConfiguration @@ -37,6 +37,9 @@ public static class GraphQlTypes public static readonly IReadOnlyDictionary ReverseMapping = new Dictionary { + { typeof(Avatar), "Avatar" }, + { typeof(PriceLevel), "PriceLevel" }, + { typeof(Resolution), "Resolution" }, { typeof(bool), "Boolean" }, { typeof(DateTimeOffset), "String" }, { typeof(long), "Int" }, diff --git a/test/GraphQlClientGenerator.Test/ExpectedSingleFileGenerationContext/DeprecatedAttributes b/test/GraphQlClientGenerator.Test/ExpectedSingleFileGenerationContext/DeprecatedAttributes index c450abf..27cee86 100644 --- a/test/GraphQlClientGenerator.Test/ExpectedSingleFileGenerationContext/DeprecatedAttributes +++ b/test/GraphQlClientGenerator.Test/ExpectedSingleFileGenerationContext/DeprecatedAttributes @@ -37,6 +37,9 @@ public static class GraphQlTypes public static readonly IReadOnlyDictionary ReverseMapping = new Dictionary { + { typeof(Avatar), "Avatar" }, + { typeof(PriceLevel), "PriceLevel" }, + { typeof(Resolution), "Resolution" }, { typeof(bool), "Boolean" }, { typeof(DateTimeOffset), "String" }, { typeof(int), "Int" }, diff --git a/test/GraphQlClientGenerator.Test/ExpectedSingleFileGenerationContext/FormatMasks b/test/GraphQlClientGenerator.Test/ExpectedSingleFileGenerationContext/FormatMasks index 34427e4..b31d322 100644 --- a/test/GraphQlClientGenerator.Test/ExpectedSingleFileGenerationContext/FormatMasks +++ b/test/GraphQlClientGenerator.Test/ExpectedSingleFileGenerationContext/FormatMasks @@ -52,6 +52,13 @@ public static class GraphQlTypes public static readonly IReadOnlyDictionary ReverseMapping = new Dictionary { + { typeof(AppScreen), "AppScreen" }, + { typeof(EnergyResolution), "EnergyResolution" }, + { typeof(HeatingSource), "HeatingSource" }, + { typeof(HomeAvatar), "HomeAvatar" }, + { typeof(HomeType), "HomeType" }, + { typeof(PriceLevel), "PriceLevel" }, + { typeof(PriceResolution), "PriceResolution" }, { typeof(string), "String" }, { typeof(DateTimeOffset), "String" }, { typeof(decimal), "Float" }, diff --git a/test/GraphQlClientGenerator.Test/ExpectedSingleFileGenerationContext/FullClientCSharpFile b/test/GraphQlClientGenerator.Test/ExpectedSingleFileGenerationContext/FullClientCSharpFile index e9cf87e..cde377f 100644 --- a/test/GraphQlClientGenerator.Test/ExpectedSingleFileGenerationContext/FullClientCSharpFile +++ b/test/GraphQlClientGenerator.Test/ExpectedSingleFileGenerationContext/FullClientCSharpFile @@ -1034,6 +1034,9 @@ namespace GraphQlGenerator.Test public static readonly IReadOnlyDictionary ReverseMapping = new Dictionary { + { typeof(Avatar), "Avatar" }, + { typeof(PriceLevel), "PriceLevel" }, + { typeof(Resolution), "Resolution" }, { typeof(bool), "Boolean" }, { typeof(DateTimeOffset), "String" }, { typeof(int), "Int" }, diff --git a/test/GraphQlClientGenerator.Test/ExpectedSingleFileGenerationContext/NewCSharpSyntaxWithClassPrefixAndSuffix b/test/GraphQlClientGenerator.Test/ExpectedSingleFileGenerationContext/NewCSharpSyntaxWithClassPrefixAndSuffix index ba63bf9..8251c1c 100644 --- a/test/GraphQlClientGenerator.Test/ExpectedSingleFileGenerationContext/NewCSharpSyntaxWithClassPrefixAndSuffix +++ b/test/GraphQlClientGenerator.Test/ExpectedSingleFileGenerationContext/NewCSharpSyntaxWithClassPrefixAndSuffix @@ -88,6 +88,8 @@ public static class GraphQlTypes public static readonly IReadOnlyDictionary ReverseMapping = new Dictionary { + { typeof(TestAvatarV1), "Avatar" }, + { typeof(TestResolutionV1), "Resolution" }, { typeof(string), "String" }, { typeof(decimal), "Float" }, { typeof(int), "Int" }, diff --git a/test/GraphQlClientGenerator.Test/ExpectedSingleFileGenerationContext/NullableReferences b/test/GraphQlClientGenerator.Test/ExpectedSingleFileGenerationContext/NullableReferences index 10e3563..d41d50d 100644 --- a/test/GraphQlClientGenerator.Test/ExpectedSingleFileGenerationContext/NullableReferences +++ b/test/GraphQlClientGenerator.Test/ExpectedSingleFileGenerationContext/NullableReferences @@ -88,6 +88,8 @@ public static class GraphQlTypes public static readonly IReadOnlyDictionary ReverseMapping = new Dictionary { + { typeof(Avatar), "Avatar" }, + { typeof(Resolution), "Resolution" }, { typeof(string), "String" }, { typeof(decimal), "Float" }, { typeof(int), "Int" }, diff --git a/test/GraphQlClientGenerator.Test/ExpectedSingleFileGenerationContext/QueryBuilders b/test/GraphQlClientGenerator.Test/ExpectedSingleFileGenerationContext/QueryBuilders index cc5ee17..ad2a95c 100644 --- a/test/GraphQlClientGenerator.Test/ExpectedSingleFileGenerationContext/QueryBuilders +++ b/test/GraphQlClientGenerator.Test/ExpectedSingleFileGenerationContext/QueryBuilders @@ -37,6 +37,9 @@ public static class GraphQlTypes public static readonly IReadOnlyDictionary ReverseMapping = new Dictionary { + { typeof(Avatar), "Avatar" }, + { typeof(PriceLevel), "PriceLevel" }, + { typeof(Resolution), "Resolution" }, { typeof(bool), "Boolean" }, { typeof(DateTimeOffset), "String" }, { typeof(int), "Int" }, diff --git a/test/GraphQlClientGenerator.Test/ExpectedSingleFileGenerationContext/SourceGeneratorResult b/test/GraphQlClientGenerator.Test/ExpectedSingleFileGenerationContext/SourceGeneratorResult index 08df461..227907e 100644 --- a/test/GraphQlClientGenerator.Test/ExpectedSingleFileGenerationContext/SourceGeneratorResult +++ b/test/GraphQlClientGenerator.Test/ExpectedSingleFileGenerationContext/SourceGeneratorResult @@ -1049,6 +1049,13 @@ namespace SourceGeneratorTestAssembly public static readonly IReadOnlyDictionary ReverseMapping = new Dictionary { + { typeof(SourceGeneratedAppScreenV2), "AppScreen" }, + { typeof(SourceGeneratedEnergyResolutionV2), "EnergyResolution" }, + { typeof(SourceGeneratedHeatingSourceV2), "HeatingSource" }, + { typeof(SourceGeneratedHomeAvatarV2), "HomeAvatar" }, + { typeof(SourceGeneratedHomeTypeV2), "HomeType" }, + { typeof(SourceGeneratedPriceLevelV2), "PriceLevel" }, + { typeof(SourceGeneratedPriceResolutionV2), "PriceResolution" }, { typeof(string), "String" }, { typeof(DateTimeOffset), "String" }, { typeof(double), "Float" }, diff --git a/test/GraphQlClientGenerator.Test/ExpectedSingleFileGenerationContext/SourceGeneratorResultWithFileScopedNamespaces b/test/GraphQlClientGenerator.Test/ExpectedSingleFileGenerationContext/SourceGeneratorResultWithFileScopedNamespaces index 800e4ae..5df7412 100644 --- a/test/GraphQlClientGenerator.Test/ExpectedSingleFileGenerationContext/SourceGeneratorResultWithFileScopedNamespaces +++ b/test/GraphQlClientGenerator.Test/ExpectedSingleFileGenerationContext/SourceGeneratorResultWithFileScopedNamespaces @@ -1049,6 +1049,13 @@ public static class GraphQlTypes public static readonly IReadOnlyDictionary ReverseMapping = new Dictionary { + { typeof(SourceGeneratedAppScreenV2), "AppScreen" }, + { typeof(SourceGeneratedEnergyResolutionV2), "EnergyResolution" }, + { typeof(SourceGeneratedHeatingSourceV2), "HeatingSource" }, + { typeof(SourceGeneratedHomeAvatarV2), "HomeAvatar" }, + { typeof(SourceGeneratedHomeTypeV2), "HomeType" }, + { typeof(SourceGeneratedPriceLevelV2), "PriceLevel" }, + { typeof(SourceGeneratedPriceResolutionV2), "PriceResolution" }, { typeof(string), "String" }, { typeof(DateTimeOffset), "String" }, { typeof(double), "Float" }, diff --git a/test/GraphQlClientGenerator.Test/ExpectedSingleFileGenerationContext/Unions b/test/GraphQlClientGenerator.Test/ExpectedSingleFileGenerationContext/Unions index 1d2cf3f..39de9bb 100644 --- a/test/GraphQlClientGenerator.Test/ExpectedSingleFileGenerationContext/Unions +++ b/test/GraphQlClientGenerator.Test/ExpectedSingleFileGenerationContext/Unions @@ -32,6 +32,7 @@ public static class GraphQlTypes public static readonly IReadOnlyDictionary ReverseMapping = new Dictionary { + { typeof(UnderscoreNamedEnum), "underscore_named_enum" }, { typeof(string), "String" }, { typeof(Guid), "ID" }, { typeof(DateTimeOffset), "DateTimeOffset" }, diff --git a/test/GraphQlClientGenerator.Test/GraphQlGeneratorTest.cs b/test/GraphQlClientGenerator.Test/GraphQlGeneratorTest.cs index 3802da3..35ff964 100644 --- a/test/GraphQlClientGenerator.Test/GraphQlGeneratorTest.cs +++ b/test/GraphQlClientGenerator.Test/GraphQlGeneratorTest.cs @@ -207,7 +207,7 @@ public void MultipleFileGeneration() fileSizes.ShouldBe( new long[] { - 446, 475, 1399, 1179, 978, 4291, 519, 569, 2132, 1942, 455, 1114, 1173, 1685, 1779, 756, 494, 1611, 498, 1438, 792, 491, 1469, 4152, 963, 762, 3703, 5073, 478, 1416, 566, 2230, 613, 2414, 1225, 7007, 447, 1250, 571, 676, 2838, 2587, 489, 1493, 461, 1312, 368, 6061, 594, 2250, 1957, 921, 7944, 879, 1530, 493, 1537, 4786, 17355, 807, 1626, 627, 2712, 10001, 972, 5274, 1101, 552, 3332, 7244, 434, 1436, 543, 501, 1549, 2001, 575, 2286, 531, 1844, 621, 2619, 767, 571, 2032, 581, 2203, 3655, 755, 3898, 588, 2198, 676, 537, 1860, 2969, 1072, 795, 4017, 5758, 898, 4540, 520, 1793, 423, 1380, 664, 751, 3597, 2913, 450, 1202, 480, 589, 559, 2013, 548, 1876, 2327, 559, 2254, 782, 853, 4477, 938, 530, 1867, 872, 4593, 584, 2116, 501, 1492, 489, 2694, 5109, 586, 2242, 558, 1985, 561, 1230, 3652, 1985 + 446, 475, 1399, 1179, 978, 4291, 519, 569, 2132, 1942, 455, 1114, 1173, 1685, 1779, 756, 494, 1611, 498, 1438, 792, 491, 1469, 4152, 963, 762, 3703, 5073, 478, 1416, 566, 2230, 613, 2414, 1225, 7007, 447, 1250, 571, 676, 2838, 2587, 489, 1493, 461, 1312, 368, 6163, 594, 2250, 1957, 921, 7944, 879, 1530, 493, 1537, 4786, 17355, 807, 1626, 627, 2712, 10001, 972, 5274, 1101, 552, 3332, 7244, 434, 1436, 543, 501, 1549, 2001, 575, 2286, 531, 1844, 621, 2619, 767, 571, 2032, 581, 2203, 3655, 755, 3898, 588, 2198, 676, 537, 1860, 2969, 1072, 795, 4017, 5758, 898, 4540, 520, 1793, 423, 1380, 664, 751, 3597, 2913, 450, 1202, 480, 589, 559, 2013, 548, 1876, 2327, 559, 2254, 782, 853, 4477, 938, 530, 1867, 872, 4593, 584, 2116, 501, 1492, 489, 2694, 5109, 586, 2242, 558, 1985, 561, 1230, 3652, 1985 }); var expectedOutput = GetTestResource("ExpectedMultipleFilesContext.Avatar");