【发布时间】:2021-01-05 10:39:56
【问题描述】:
我对 GraphQL.Net 库有疑问。我用过“GraphQL”版本=“3.2.0”、“GraphQL.Server.Ui.Playground”版本=“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”。 谁能告诉我,我的错误在哪里?
【问题讨论】:
标签: c# .net-core-3.0 graphql-dotnet