IObjectTypeDescriptor ResolverWith Obtain the Fields Value Only #3121
-
Hi there, Firstly thanks for all the hard work on hot chocolate, it has been a great aid for my project I am currently working on. I am not a developer but do have experience working with c# and have managed to follow most of the documentation perfectly fine. One thing that has eluded me is how the resolvers work for the descriptor. Lets say I have this object: public class MyObject
{
public int Id { get; set; }
public string Name { get; set; }
[TimeStamp]
public byte[] RowVersion { get; set; }
} I then define the object type using code-first as: public class MyObjectType : ObjectType<MyObject>
{
protected override void Configure(IObjectTypeDescriptor<MyObject> descriptor)
{
descriptor
.ResolveWith<SomeResolver>(o => o.GetSomething(default));
// how do I make this work?
descriptor
.ResolveWith<SomeResolver>(o => o.GetSomethingFieldValue(default));
}
private class SomeResolver
{
public string GetSomething(MyObject myObject)
{
return myObject.Name;
}
// how can I just pass in the value of the field??!
public string GetSomethingFieldValue(string name)
{
return name;
}
}
} I would love to just pass in the value of the field, then I can make my resolver class more generic. Then I can just have a global resolver that takes an input and gives an output etc. if that makes sense. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
This is something we are discussing but have not found a nice enough way so far. Sometime you do want to have two fields and sometimes a field completely unrelated to the one you are resolving. We will discuss changes to this for the May release. |
Beta Was this translation helpful? Give feedback.
This is something we are discussing but have not found a nice enough way so far. Sometime you do want to have two fields and sometimes a field completely unrelated to the one you are resolving. We will discuss changes to this for the May release.