Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

There was no argument with the name `...` found on the field `...`

I'm using HotChocolate 12.0.1. I have following type definition:

    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;
            }
        }
    }

I expect injection of My object in TestResolver Get(My my) after it is populated with Logo value, as I've seen in example: https://github.com/ChilliCream/graphql-workshop/blob/master/docs/3-understanding-dataLoader.md

But for some reason, I've got from HotChocolate parameter lookup:

    There was no argument with the name `my` found on the field `name`.

My query:

    query {
      my(someId: 123) {
        name
        logo
      }
    }

Startup:

            services.AddGraphQLServer()
                .AddQueryType<QueryType>()
                .AddType<MyType>()

Where could be the problem?

like image 572
Pavel Avatar asked Dec 31 '22 12:12

Pavel


1 Answers

Really silly solution which took me 4 hours to find.

private class TestResolver
{
    public string Get([Parent] My my)
    {
        return my.Logo;
    }
}

Relevant documentation:

  • https://chillicream.com/docs/hotchocolate/api-reference/migrate-from-11-to-12#resolvers
  • https://github.com/ChilliCream/hotchocolate/issues/4292
like image 140
Jeremy Avatar answered Jan 05 '23 18:01

Jeremy