Pav*_*vel 9 c# graphql asp.net-core hotchocolate
我正在使用热巧克力 12.0.1。我有以下类型定义:
public class MyType : ObjectType<My>
{
protected override void Configure(IObjectTypeDescriptor<My> descriptor)
{
descriptor.Field(p => p.Name)
.ResolveWith<TestResolver>(r => r.Get(default))
.Type<IdType>();
descriptor.Field(p => p.Logo)
.Type<StringType>();
}
private class TestResolver
{
public string Get(My my)
{
return my.Logo;
}
}
}
Run Code Online (Sandbox Code Playgroud)
我期望在填充 Logo 值后在 TestResolver Get(My my) 中注入 My 对象,正如我在示例中看到的那样: https: //github.com/ChilliCream/graphql-workshop/blob/master/docs/3 -理解-dataLoader.md
但由于某种原因,我从 HotChocolate 参数查找中得到:
There was no argument with the name `my` found on the field `name`.
Run Code Online (Sandbox Code Playgroud)
我的查询:
query {
my(someId: 123) {
name
logo
}
}
Run Code Online (Sandbox Code Playgroud)
启动:
services.AddGraphQLServer()
.AddQueryType<QueryType>()
.AddType<MyType>()
Run Code Online (Sandbox Code Playgroud)
问题可能出在哪里?
Jer*_*emy 25
真是愚蠢的解决方案,我花了 4 个小时才找到。
private class TestResolver
{
public string Get([Parent] My my)
{
return my.Logo;
}
}
Run Code Online (Sandbox Code Playgroud)
相关文档:
| 归档时间: |
|
| 查看次数: |
2526 次 |
| 最近记录: |