在字段 `...` 上找不到名称为 `...` 的参数
There was no argument with the name `...` found on the field `...`
我正在使用 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;
}
}
}
我希望在 TestResolver Get(My my) 中注入 My 对象,然后用 Logo 值填充它,如我在示例中所见:
https://github.com/ChilliCream/graphql-workshop/blob/master/docs/3-understanding-dataLoader.md
但出于某种原因,我从 HotChocolate 参数查找中得到:
There was no argument with the name `my` found on the field `name`.
我的查询:
query {
my(someId: 123) {
name
logo
}
}
启动:
services.AddGraphQLServer()
.AddQueryType<QueryType>()
.AddType<MyType>()
问题出在哪里?
非常愚蠢的解决方案,我花了 4 个小时才找到。
private class TestResolver
{
public string Get([Parent] My my)
{
return my.Logo;
}
}
相关文档:
我正在使用 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;
}
}
}
我希望在 TestResolver Get(My my) 中注入 My 对象,然后用 Logo 值填充它,如我在示例中所见: https://github.com/ChilliCream/graphql-workshop/blob/master/docs/3-understanding-dataLoader.md
但出于某种原因,我从 HotChocolate 参数查找中得到:
There was no argument with the name `my` found on the field `name`.
我的查询:
query {
my(someId: 123) {
name
logo
}
}
启动:
services.AddGraphQLServer()
.AddQueryType<QueryType>()
.AddType<MyType>()
问题出在哪里?
非常愚蠢的解决方案,我花了 4 个小时才找到。
private class TestResolver
{
public string Get([Parent] My my)
{
return my.Logo;
}
}
相关文档: