Closed rspeele closed 7 years ago
This is done, but we should add tests.
Could you clarify how is this used in a query? I am getting message that "...is not a member of any known enum type"
This is either not implemented fully, or I don't understand enough of what is going on but in CS.fs, ResolveEnumValue always returns null when I debug because of this line
default this.ResolveEnumValue() = Unchecked.defaultof<>
and Schema.cs does not seem to be overriding this member.
Hmm, you're absolutely right. Seems like we're not providing a way to resolve the enum in the schema adapter, so it's just defaulting to null.
I think you can close this issue...
GraphQL enums are weird.
They're just identifiers that don't fit any of the other patterns - not variable names, not true, false, or null. We need to be able to distinguish between
Color.Orange
andFruit.Orange
. To avoid having to do some crazy inference thing where we leave the enum type unresolved until the point at which it's used, let's let people define a prefix with enums.This could be something like:
schema.AddEnum<Fruit>(prefix: "Fruit_")
Ideally it should work similarly to the general primitive type alias support, where if you've run that
AddEnum
call, you can use anonymous types with that CLR enum type in your field args without issue and with all the schema validation you'd expect.