Closed
Description
Product
Hot Chocolate
Version
15.1.3
Link to minimal reproduction
https://github.com/mathieu-radyo/HotChocolate-IssueReproductions
Steps to reproduce
- Create a GraphQL query using
[UseConnection]
,[UseFiltering]
,[UseSorting]
and[UseProjection]
on a resolver that returnsPageConnection<T>
. - Try to query a parent entity and its related children (e.g.
countries
and theircities
). - Run the query via GraphQL Playground or Studio.
Example code:
[UseConnection]
[UseProjection]
[UseFiltering]
[UseSorting]
public static async Task<PageConnection<Country>> GetCountriesAsync(
[Service] WorldContext context,
PagingArguments pagingArguments,
QueryContext<Country> query,
CancellationToken cancellationToken = default)
{
var page = await context.Countries.AsNoTracking()
.With(query, c => c.IfEmpty(i => i.AddAscending(e => e.Id)))
.ToPageAsync(pagingArguments, cancellationToken);
return new PageConnection<Country>(page);
}
GraphQL query used:
query {
countries(first: 5) {
pageInfo {
hasNextPage
hasPreviousPage
startCursor
endCursor
forwardCursors {
page
cursor
}
backwardCursors {
page
cursor
}
}
nodes {
id
name
emoji
emojiU
capital
cities {
name
wikiDataId
}
}
edges {
cursor
}
totalCount
}
}
What is expected?
I expect to be able to combine [UseConnection]
with [UseProjection]
to:
- Benefit from relative cursor-based pagination (
forwardCursors
,backwardCursors
) - Apply filtering, sorting, and projection
- Fetch related child entities like
cities
without overfetching
What is actually happening?
-
The query fails at startup or runtime with the following error:
System.ArgumentException: Type 'HotChocolate.Types.Pagination.PageConnection`1[...]' does not have a default constructor (Parameter 'type')
-
If I remove
[UseProjection]
, the query runs — but child entities likecities
are no longer included, even if defined in the GraphQL schema.
Relevant log output
Additional context
The issue is reproducible in this minimal GitHub repo:
🔗 https://github.com/mathieu-radyo/HotChocolate-IssueReproductions
Questions:
- Is this limitation expected?
- Will
UseProjection
eventually supportPageConnection<T>
? - Is there a recommended workaround to get child entities with relative cursors?
Thanks in advance for your help and your work on this great library!