If I try to expose a class using graphQl I’m getting below error. I know this error is due to char type that I’m using, but I cannot change the structure.
HotChocolate.SchemaException: For more details look at the Errors` property.
Unable to infer or resolve a schema type from the type reference Output: Char.
at HotChocolate.Configuration.TypeInitializer.DiscoverTypes()
at HotChocolate.Configuration.TypeInitializer.Initialize()
This is my class structure
class Room{
[StringLength(1)]
public char RoomStatus { get; set; }
}
Any help would be appreciated. Thanks in advance.
2
Answers
In GraphQL there is no char type. You can explicitly bind it to string if you want to. In Startup file add below line
The error can be resolved by binding char to StringType of graphQl and adding a TypeConverter from char to string. This should be done in the builder.Services as follows