Flags enums are not correctly inferred.
See original GitHub issueDescribe the bug
If we infer a enum type form a flags enum like HotChocolate.Types.EnumType<System.Reflection.TypeAttributes
we will run in to an error that the value names cannot be correctly inferred since each value can have multiple states leading to names like:
AUTOLAYOUT, ANSICLASS, CLASS, PUBLIC
To Reproduce
var schema = SchemaBuilder.New()
.AddQueryType(c => c
.Name("Query")
.Field("foo")
.Type<StringType>()
.Resolver("bar"))
.AddType<HotChocolate.Types.EnumType<System.Reflection.TypeAttributes>>()
.Create();
Expected behavior
This still has to be defined. Do we infer those as a list of enums. Leading to things like [[MyFlagsEnum]]
?
Environment (please complete the following information):
- Version 10.0.1
Issue Analytics
- State:
- Created 4 years ago
- Reactions:3
- Comments:7 (6 by maintainers)
Top Results From Across the Web
Flags enums are not correctly inferred. · Issue #1020
Describe the bug If we infer a enum type form a flags enum like HotChocolate.Types. ... Flags enums are not correctly inferred. #1020....
Read more >c# - Enum Flags Negative Value
All I am given is a int property with the reason, and an SDK that says check this reason against a bit mask...
Read more >The trouble with TypeScript enums
In TypeScript, enums have a few surprising limitations. In particular, it can be challenging to check whether or not a value is in...
Read more >How To Use Enums in TypeScript
In TypeScript, enums, or enumerated types, are data structures of constant length that hold a set of constant values.
Read more >design patterns - Is it a good practice to use List of Enums?
When some enum member is not a valid flag in some scenario, consider splitting the enum into multiple distinct enums.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Plans yes, but it’s not a trivial change and there are a couple of other things before it in the backlog.
Essentially it would make sense to map the flag enum into a type:
I guess as a workaround you could just define this type yourself
Gotcha; so it sounds like the guidance right now is to add a converter to treat it (from the client perspective) as a numeric value, but the converter can convert it to the enum flags?
Is there a list of work to do for this? We use flags for a bunch of things in my company’s product, so I’d be interested in helping out 😃