I have a graphQL query where I have 10 parallel queries + 2 properties on the second level. This results in 12 queries (10 queries + 2 batched properties).
{
entries0(pageSize: 10) {
id
project {
id
}
partner {
id
}
}
entries1(pageSize: 10) {
id
project {
id
}
partner {
id
}
}
}
This is when I forced a serial execution strategy:
And this is when I use the parallel execution strategy:
As you can see, concurrent DB requests do happen now, but they do not start at the same time. What could be the cause of this?
I use GraphQL.NET 4.7.1 with .NET 6.0 and EF Core 6.0.2.
This is the query (duplicated 10 times: entries0, entries1, etc...):
Field<ListGraphType<Entry>, List<EntryEntity>>()
.Name("entries0")
.Argument<NonNullGraphType<IntGraphType>>("pageSize")
.ResolveScopedAsync(ctx =>
{
int pageSize = ctx.GetArgument<int>("pageSize");
var manager = ctx.RequestServices.GetRequiredService<ITestManager>();
return manager.GetMultiple(pageSize);
});
And this is the code from the manager
public Task<List<EntryEntity>> GetMultiple(int take)
{
return _dbContext.EntryEntities
.OrderByDescending(x => x.CreatedOn)
.Take(take)
.ToListAsync();
}
So as I see it the query does execute in parallel, but I don't see why it doesn't fully run in parallel. Each dbContext runs as separate instance in its own scope thanks to ResolveScopedAsync.