Skip to content
Merged
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
13 changes: 13 additions & 0 deletions src/HotChocolate/Core/src/Types/Types/EnumTypeExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,22 @@ private void MergeValues(
}
else
{
existingValue.Name = enumValue.Name;

if (enumValue.Description is not null)
{
existingValue.Description = enumValue.Description;
}

if (enumValue.IsDeprecated)
{
existingValue.DeprecationReason = enumValue.DeprecationReason;
}

existingValue.Ignore = enumValue.Ignore;

TypeExtensionHelper.MergeFeatures(enumValue, existingValue);
TypeExtensionHelper.MergeConfigurations(enumValue.Tasks, existingValue.Tasks);

TypeExtensionHelper.MergeDirectives(
context,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,22 @@ public void EnumTypeExtension_Ignore_Fields()
schema.ToString().MatchSnapshot();
}

[Fact]
public void EnumTypeExtension_Rename_Value()
{
// act
var schema = SchemaBuilder.New()
.AddQueryType<DummyQuery>()
.AddType<FooType>()
.AddType<FooRenameTypeExtension>()
.Create();

// assert
var type = schema.Types.GetType<EnumType>("Foo");
Assert.True(type.TryGetRuntimeValue("TEST", out _));
Assert.False(type.TryGetRuntimeValue("BAR", out _));
}

public class DummyQuery
{
public required string Foo { get; set; }
Expand Down Expand Up @@ -169,6 +185,16 @@ protected override void Configure(IEnumTypeDescriptor descriptor)
}
}

public class FooRenameTypeExtension
: EnumTypeExtension
{
protected override void Configure(IEnumTypeDescriptor descriptor)
{
descriptor.Name("Foo");
descriptor.Value(Foo.Bar).Name("TEST");
}
}

public enum Foo
{
Bar,
Expand Down
Loading