Skip to content

Commit

Permalink
Fix: Added Enum to GraphQLDescriptionAttribute (#2430)
Browse files Browse the repository at this point in the history
  • Loading branch information
PascalSenn committed Oct 14, 2020
1 parent 8299a94 commit 9ef8f5f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
Expand Up @@ -7,6 +7,7 @@ namespace HotChocolate
| AttributeTargets.Interface
| AttributeTargets.Property
| AttributeTargets.Method
| AttributeTargets.Enum
| AttributeTargets.Parameter
| AttributeTargets.Field)]
public sealed class GraphQLDescriptionAttribute
Expand Down
22 changes: 22 additions & 0 deletions src/HotChocolate/Core/test/Types.Tests/Types/EnumTypeTests.cs
Expand Up @@ -32,6 +32,22 @@ public void EnumType_DynamicName()
Assert.NotNull(type);
}

[Fact]
public void EnumType_GraphQLDescriptionAttribute()
{
// act
var schema = Schema.Create(c =>
{
c.RegisterType(new EnumType<DescriptionTestEnum>());
c.Options.StrictValidation = false;
});

// assert
EnumType type = schema.GetType<EnumType>("DescriptionTestEnum");
Assert.Equal("TestDescription", type.Description);
}

[Fact]
public void EnumType_DynamicName_NonGeneric()
{
Expand Down Expand Up @@ -590,5 +606,11 @@ protected override void Configure(IEnumTypeDescriptor<string> descriptor)
descriptor.Value("ABC").Name("DEF");
}
}

[GraphQLDescription("TestDescription")]
public enum DescriptionTestEnum
{
Foo, Bar
}
}
}

0 comments on commit 9ef8f5f

Please sign in to comment.