如果我试图使用graphQl公开一个类,我就会出现以下错误。我知道这个错误是由于我正在使用的char类型造成的,但是我不能更改结构。
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()这是我的类结构
class Room{
[StringLength(1)]
public char RoomStatus { get; set; }
}任何帮助都将不胜感激。提前谢谢。
发布于 2022-06-16 11:24:29
在GraphQL中不存在char类型。如果愿意,可以显式地将其绑定到字符串。在启动文件中添加以下行
services.AddGraphQLServer()
.BindRuntimeType<char, StringType>()发布于 2022-07-27 09:36:27
该错误可以通过将char绑定到StringType of graphQl并从char添加到TypeConverter来解决。这应该在builder.Services中完成,如下所示
builder.Services.
AddGraphQLServer().
BindRuntimeType<char, StringType>().
AddTypeConverter<char, string>(from => from.ToString());https://stackoverflow.com/questions/70694080
复制相似问题