I'm using HotChocolate with Entity Framework. For some fields, we want to filter One-to-Many collections.
Example :
public class Many
{
public int Id { get; set; }
public string? Name {get; set; }
}
public class User
{
public int Id { get; set; }
public List<Many> Manies { get; set; }
}
public class UserType : ObjectType<User>
{
protected override void Configure(IObjectTypeDescriptor<User> descriptor)
{
descriptor.BindFieldsExplicitly();
descriptor.Field(u => u.Id);
descriptor.Field("manies").Resolve(c => c.Parent<User>().Manies.Where(m => m.Name.StartsWith("A")).ToList());
}
}
My first question is : Are resolver executed in parallel as stated by HotChocolate documentation for v10 ?
Also I have an issue when I use async/await in Resolver. It seems that in that case (and only in that case) the resolver is launched on another thread (and I'm having issue with DbContext parallel execution).
Example :
descriptor.Field("manies").Resolve(async c => {
var parent = c.Parent<User>();
return await GetFilterManiesAsync(parent);
});
But when I force sync, no parallel issue :
descriptor.Field("manies").Resolve(c => {
var parent = c.Parent<User>();
return GetFilterManiesAsync(parent).Result;
});
So I'm trying to understand, is this a bug in HotChocolate ? Or is the parallel pipeline only launched on async/await resolver.
P.S. Using HotChocolate v11.0.9
Thanks,