You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I use a combination of Implementation First to handle certain directives (database context, includes, and projection) and CodeFirst to handle descriptors (paging, filtering, projection directives).
The entities arrangement like this:
TestRuns has an ICollection of Executions; which are projected into TestRunReponse with deep handling of each of its objects nested to objects of type ...Response.
TestRunResponse:
public class TestRunResponse : BaseResponse
{
..
public ICollection<ExecutionResponse?>? Executions { get; init; }
public ICollection<LabelResponse?>? Labels { get; init; }
public ICollection<RunParamResponse?>? RunParams { get; init; }
...
}
GraphQueryHandler (The resultant objects for the query are mapped to TestRunResponse:
public IQueryable<TestRunResponse> TestRuns([Service] ReadDatabaseContext databaseContext)
{
// Include necessary relationships to prevent lazy loading and optimize performance.
return databaseContext.TestRuns
.Include(t => t.TestRunExecutions)
.Include(t => t.TestRunLabels)
.Include(t => t.TestRunParams)
.Include(t => t.Platform)
.AsNoTracking()
.ProjectTo<TestRunResponse>(Mapper.ConfigurationProvider);
}
GraphQueryType:ObjectType (Support for paging the nested object ):
protected override void Configure(IObjectTypeDescriptor<GraphQueryHandler> descriptor)
{
// Defines a field for fetching test runs, returning a TestRunResponseType.
descriptor.Field(f => f.TestRuns(default!))
.Type<TestRunResponseType>()
.UseOffsetPaging(options: new PagingOptions
{
IncludeTotalCount = true,
MaxPageSize = 50,
AllowBackwardPagination = true
})
.UseProjection()
.UseFiltering()
.UseSorting();
}
TestRunResponseType : ObjectType:
{
/// <summary>
/// Configures the GraphQL TestRunResponse type, enabling filtering on the "Executions" field.
/// </summary>
/// <param name="descriptor">Descriptor used to define fields and configurations for the type.</param>
protected override void Configure(IObjectTypeDescriptor<TestRunResponse> descriptor)
{
// Enables filtering on the "Executions" field using HotChocolate.
descriptor.Field(t => t.Executions)
.UsePaging(options: new PagingOptions
{
IncludeTotalCount = true,
MaxPageSize = 50,
AllowBackwardPagination = true
})
.UseFiltering()
.UseSorting();
}
}
What is expected?
The nested objects returned over the query needs to be NotNull and Populated
What is actually happening?
Once I add support for paging nested objects in a query, the response object is always null, meanwhile In a normal query (without paging nested objects) the resultant objects are populated (right behaviour)
Relevant log output
Additional context
Query:
query { testRuns(take: 10, skip: 0) { items { id version originType platform { name } executions( first: 5 ) { edges { node { id } cursor } pageInfo { endCursor hasNextPage } } runParams { key value } } pageInfo { hasNextPage hasPreviousPage } totalCount } }
// Configures the "Executions" field of the TestRunResponse type.
// Enables resolution using the specific resolver to obtain the executions.
descriptor.Field(t => t.Executions)
.ResolveWith<TestRunResolver>(r => r.Executions(default!, default!))
Product
Hot Chocolate
Version
15.0.3
Link to minimal reproduction
https://gist.github.com/aviiliix/12fa5c64de0bf119b5744eb28dc1c33a
Steps to reproduce
SDK & Packages:
I use a combination of Implementation First to handle certain directives (database context, includes, and projection) and CodeFirst to handle descriptors (paging, filtering, projection directives).
The entities arrangement like this:
TestRuns has an ICollection of Executions; which are projected into TestRunReponse with deep handling of each of its objects nested to objects of type ...Response.
TestRunResponse:
Startup:
GraphQueryHandler (The resultant objects for the query are mapped to TestRunResponse:
GraphQueryType:ObjectType (Support for paging the nested object ):
TestRunResponseType : ObjectType:
What is expected?
The nested objects returned over the query needs to be NotNull and Populated
What is actually happening?
Once I add support for paging nested objects in a query, the response object is always null, meanwhile In a normal query (without paging nested objects) the resultant objects are populated (right behaviour)
Relevant log output
Additional context
Query:
query { testRuns(take: 10, skip: 0) { items { id version originType platform { name } executions( first: 5 ) { edges { node { id } cursor } pageInfo { endCursor hasNextPage } } runParams { key value } } pageInfo { hasNextPage hasPreviousPage } totalCount } }
Response:
{ "data": { "testRuns": { "items": [ { "id": "13c451f3-680d-42dd-ab8b-2339f0c1fecc", "version": "584v10-584010", "originType": "CLOUD", "platform": { "name": "CV-ADR" }, "executions": null, // <---- Here lies the error "runParams": [ { "key": "ipCharles", "value": "-ipsp 0.0.0.0" }, { "key": "portAppium", "value": "-sp 4728" }, ....
The text was updated successfully, but these errors were encountered: