9

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?

Pavel
  • 653
  • 2
  • 11
  • 31
  • 1
    I'm also facing this issue in [this tutorial](https://www.youtube.com/watch?v=HuN94qNwQmM&t=9531s) :/ I tried debugging, and it seems like the resolver is not being used – Jeremy Oct 06 '21 at 00:25

1 Answers1

24

Really silly solution which took me 4 hours to find.

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

Relevant documentation:

Jeremy
  • 1,447
  • 20
  • 40
  • 1
    This was exactly what I needed. There are a few YouTube tutorials out there that are written on V11, and this simple solution fixed the problem. Thank you! – tscrip Nov 04 '21 at 15:47
  • Yeah, I don't know why this would be buried deep into the documentation, lol – Jeremy Nov 10 '21 at 05:21