ChilliCream / ChilliCream/graphql-platform
Rename AutoGenerated Type for Flags Enum
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 5.8k
- Forks
- 810
- Avg merge
- 15h 39m
- Merged PRs (30d)
- 98
Description
Product
Hot Chocolate
Is your feature request related to a problem?
Not long ago a feature was introduced for supporting enums with [Flags] attribute.
https://github.com/ChilliCream/graphql-platform/pull/5186
Currently there is no way to rename this auto generated type. Example:
[Flags]
public enum MyEnum {
A
B
C
}
public class MyEnumType : EnumType<MyEnum>
{
protected override Configure(IEnumTypeDescriptor<MyEnum> descriptor)
{
descriptor.Name("MyRenamedEnum");
}
}
Will generate the following:
enum MyRenamedEnum {
A
B
C
}
type MyEnumFlags {
isA: Boolean!
isB: Boolean!
isC: Boolean!
}
Notice that MyEnumFlags is used rather than MyRenamedEnumFlags.
The solution you'd like
Flags enums are supported through TypeInterceptors and not a specific type. As I'm not familiar with these, I'm unsure the best way to support this.
Ideas:
public class MyEnumType : EnumFlagsType<MyEnum>
{
protected override Configure(IEnumFlagsTypeDescriptor<MyEnum> descriptor)
{
descriptor.Name("MyRenamedEnum");
}
}
Another solution would be to support respecting the original EnumType. The trick here is determining whether the developer
wants the flags type, or actually wants to use the enum type despite flags being enabled.
public class MyEnumType : EnumType<MyEnum>
{
protected override Configure(IEnumTypeDescriptor<MyEnum> descriptor)
{
descriptor.Name("MyRenamedEnum");
}
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing PR #5186 and the TypeInterceptors that generate the flags enum type. Trace how the original enum name is obtained and confirm that configuring the enum as MyRenamedEnum produces MyRenamedEnumFlags rather than MyEnumFlags; add coverage for the example behavior if the relevant tests are found.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- api, backend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100