Skip to content
Open
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
4 changes: 2 additions & 2 deletions src/GraphQlClientGenerator/GraphQlGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ public static class GraphQlTypes
public static readonly IReadOnlyDictionary<Type, string> ReverseMapping =
new Dictionary<Type, string>
{
{ typeof(Avatar), "Avatar" },
{ typeof(PriceLevel), "PriceLevel" },
{ typeof(Resolution), "Resolution" },
{ typeof(bool), "Boolean" },
{ typeof(DateTimeOffset), "String" },
{ typeof(int), "Int" },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ public static class GraphQlTypes
public static readonly IReadOnlyDictionary<Type, string> ReverseMapping =
new Dictionary<Type, string>
{
{ typeof(Avatar), "Avatar" },
{ typeof(PriceLevel), "PriceLevel" },
{ typeof(Resolution), "Resolution" },
{ typeof(bool), "Boolean" },
{ typeof(DateTimeOffset), "String" },
{ typeof(long), "Int" },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ public static class GraphQlTypes
public static readonly IReadOnlyDictionary<Type, string> ReverseMapping =
new Dictionary<Type, string>
{
{ typeof(Avatar), "Avatar" },
{ typeof(PriceLevel), "PriceLevel" },
{ typeof(Resolution), "Resolution" },
{ typeof(bool), "Boolean" },
{ typeof(DateTimeOffset), "String" },
{ typeof(int), "Int" },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@ public static class GraphQlTypes
public static readonly IReadOnlyDictionary<Type, string> ReverseMapping =
new Dictionary<Type, string>
{
{ 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" },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1034,6 +1034,9 @@ namespace GraphQlGenerator.Test
public static readonly IReadOnlyDictionary<Type, string> ReverseMapping =
new Dictionary<Type, string>
{
{ typeof(Avatar), "Avatar" },
{ typeof(PriceLevel), "PriceLevel" },
{ typeof(Resolution), "Resolution" },
{ typeof(bool), "Boolean" },
{ typeof(DateTimeOffset), "String" },
{ typeof(int), "Int" },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ public static class GraphQlTypes
public static readonly IReadOnlyDictionary<Type, string> ReverseMapping =
new Dictionary<Type, string>
{
{ typeof(TestAvatarV1), "Avatar" },
{ typeof(TestResolutionV1), "Resolution" },
{ typeof(string), "String" },
{ typeof(decimal), "Float" },
{ typeof(int), "Int" },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ public static class GraphQlTypes
public static readonly IReadOnlyDictionary<Type, string> ReverseMapping =
new Dictionary<Type, string>
{
{ typeof(Avatar), "Avatar" },
{ typeof(Resolution), "Resolution" },
{ typeof(string), "String" },
{ typeof(decimal), "Float" },
{ typeof(int), "Int" },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ public static class GraphQlTypes
public static readonly IReadOnlyDictionary<Type, string> ReverseMapping =
new Dictionary<Type, string>
{
{ typeof(Avatar), "Avatar" },
{ typeof(PriceLevel), "PriceLevel" },
{ typeof(Resolution), "Resolution" },
{ typeof(bool), "Boolean" },
{ typeof(DateTimeOffset), "String" },
{ typeof(int), "Int" },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1049,6 +1049,13 @@ namespace SourceGeneratorTestAssembly
public static readonly IReadOnlyDictionary<Type, string> ReverseMapping =
new Dictionary<Type, string>
{
{ 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" },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1049,6 +1049,13 @@ public static class GraphQlTypes
public static readonly IReadOnlyDictionary<Type, string> ReverseMapping =
new Dictionary<Type, string>
{
{ 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" },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public static class GraphQlTypes
public static readonly IReadOnlyDictionary<Type, string> ReverseMapping =
new Dictionary<Type, string>
{
{ typeof(UnderscoreNamedEnum), "underscore_named_enum" },
{ typeof(string), "String" },
{ typeof(Guid), "ID" },
{ typeof(DateTimeOffset), "DateTimeOffset" },
Expand Down
2 changes: 1 addition & 1 deletion test/GraphQlClientGenerator.Test/GraphQlGeneratorTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down