I'm new to HotChocolate and graphql but this issue that I have at the moment with HotChocolate is a bit strange.
So I'm using the following packages in a dotnet 6.0 webapi project:
- HotChocolate.AspNetCore @ 12.5.0
- HotChocolate.AspNetCore.Authorization @ 12.5.0
- HotChocolate.Data @ 12.5.0
- HotChocolate.Types.Scalars @ 12.5.0
I have a query like beloew
public IQueryable<EmploymentContract> GetEmploymentContracts([Service] ApplicationDbContext dbContext)
=> dbContext.EmploymentContracts
.Include(x => x.Person)
.Include(x => x.Organisation)
.Include(x => x.Department);
and then a descriptor for it like
descriptor.Field(x => x.GetEmploymentContracts(_dbContext))
.UsePaging(options: new PagingOptions { DefaultPageSize = PAGE_SIZE, IncludeTotalCount = true })
.UseFiltering()
.UseSorting();
Now the issue is that if I run a query like below, it takes even sometimes more than 30 seconds to give back the results. I checked the ef core
generated sql query
and that runs in mssql in 200ms
. Whatever is slowing down the request, is happening after ef core runs the query and gets the result from the database.
{
employmentContracts {
nodes {
personnelNumber
}
}
}
As you see, the above query is really simple.
When I remove the UsePaging
it works fine and I get the results immediately.
But if not, it either will give a timeout
or will run for 22s or so...
Edit
The problem is solved and the issue was not with GraphQL. The model had some images stored in places where the query was happening. The model is changed and the issue is not happening anymore.