我对 GraphQL.Net 库有疑问。我使用了 "GraphQL" Version="3.2.0"、"GraphQL.Server.Ui.Playground" Version="4.4.0" 和 TargetFramework = netcoreapp3.0 我想看看它是如何工作的,我创建了一个简单的类:
public class Temp
{
public int MyProperty { get; set; }
}
public class TempType : ObjectGraphType<Temp>
{
public TempType()
{
Name = "TEmp";
Field(t => t.MyProperty).Description("temp");
}
}
public class SolDataQuery : ObjectGraphType
{
public SolDataQuery(ISolDataFill sdFill)
{
Name = "Query";
Field<IntGraphType>("soldata", resolve: context => 5);
Field<TempType>("wheater", resolve: context => new Temp { MyProperty = 2 });
}
}
在操场上开始后,我请求了一个查询:{wheather {myProperty}},我看到:“消息”:“执行文档时出错。”,“代码”:“INVALID_OPERATION”。如果我更改了代码和注释行“Field("wheater", resolve: context => new Temp { MyProperty = 2 });” 我请求查询 {soldata} 并看到正确的结果“5”。谁能告诉我,我的错误在哪里?