Skip to content

Commit

Permalink
Updated NameUtils.GetEnumValue to preserve leading underscore (#7272)
Browse files Browse the repository at this point in the history
  • Loading branch information
glen-84 authored Jul 19, 2024
1 parent a7ce3ac commit 0605e2a
Show file tree
Hide file tree
Showing 3 changed files with 507 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ public static string GetEnumValue(string enumValue)
if (enumValue[i] == '_')
{
upper = true;

if (i == 0)
{
value.Append('_');
}
}
else if (upper)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -529,4 +529,32 @@ query GetPeopleByPk($id: uuid!) {
"extend schema @key(fields: \"id\")",
FileResource.Open("HasuraSchema.graphql"));
}

[Fact]
public void EnumWithUnderscorePrefixedValues()
{
AssertResult(
"""
schema {
query: Query
}

type Query {
field1: Enum1
}

enum Enum1 {
_a # -> "_A"
_a_b # -> "_AB"
_1 # -> "_1"
_1_2 # -> "_12"
__2 # -> "_2"
}
""",
"""
query GetField1 {
field1
}
""");
}
}
Loading

0 comments on commit 0605e2a

Please sign in to comment.