Repository navigation
Labels
Area: DataIssue is related to filtering, sorting, pagination or projectionsArea: Projectionsrepro-validated🌶️ hot chocolate
Description
Is there an existing issue for this?
- I have searched the existing issues
Product
Hot Chocolate
Describe the bug
I've tested on the latest version of HotChocolate (13.0.5).
The JsonDocument works fine if I don't use the UseProjection attribute. IF I use it I get the following error:
{
"errors": [
{
"message": "Unexpected Execution Error",
"locations": [
{
"line": 2,
"column": 3
}
],
"path": [
"testes"
],
"extensions": {
"message": "Type 'System.Text.Json.JsonDocument' does not have a default constructor (Parameter 'type')",
"stackTrace": " at System.Linq.Expressions.Expression.New(Type type)\r\n at HotChocolate.Data.Projections.Expressions.QueryableProjectionScopeExtensions.CreateMemberInit(QueryableProjectionScope scope)\r\n at HotChocolate.Data.Projections.Expressions.Handlers.QueryableProjectionFieldHandler.TryHandleLeave(QueryableProjectionContext context, ISelection selection, ISelectionVisitorAction& action)\r\n at HotChocolate.Data.Projections.ProjectionVisitor`1.Leave(ISelection selection, TContext context)\r\n at HotChocolate.Data.Projections.SelectionVisitor`1.Visit(ISelection selection, TContext context)\r\n at HotChocolate.Data.Projections.SelectionVisitor`1.VisitObjectType(IOutputField field, ObjectType objectType, ISelection selection, TContext context)\r\n at HotChocolate.Data.Projections.Expressions.QueryableProjectionVisitor.VisitObjectType(IOutputField field, ObjectType objectType, ISelection selection, QueryableProjectionContext context)\r\n at HotChocolate.Data.Projections.SelectionVisitor`1.VisitChildren(IOutputField field, TContext context)\r\n at HotChocolate.Data.Projections.SelectionVisitor`1.Visit(IOutputField field, TContext context)\r\n at HotChocolate.Data.Projections.ProjectionVisitor`1.Visit(IOutputField field, TContext context)\r\n at HotChocolate.Data.Projections.ProjectionVisitor`1.Visit(TContext context, ISelection selection)\r\n at HotChocolate.Data.Projections.Expressions.QueryableProjectionProvider.<CreateApplicator>b__7_0[TEntityType](IResolverContext context, Object input)\r\n at HotChocolate.Data.Projections.Expressions.QueryableProjectionProvider.<>c__DisplayClass4_0`1.<<CreateExecutor>g__ExecuteAsync|1>d.MoveNext()\r\n--- End of stack trace from previous location ---\r\n at HotChocolate.Data.ToListMiddleware`1.InvokeAsync(IMiddlewareContext context)\r\n at HotChocolate.Resolvers.Expressions.Parameters.ServiceHelper.<>c__DisplayClass7_3`1.<<UseResolverServiceInternal>b__5>d.MoveNext()\r\n--- End of stack trace from previous location ---\r\n at HotChocolate.Resolvers.Expressions.Parameters.ServiceHelper.<>c__DisplayClass7_1`1.<<UseResolverServiceInternal>b__3>d.MoveNext()\r\n--- End of stack trace from previous location ---\r\n at HotChocolate.Execution.Processing.Tasks.ResolverTask.ExecuteResolverPipelineAsync(CancellationToken cancellationToken)\r\n at HotChocolate.Execution.Processing.Tasks.ResolverTask.TryExecuteAsync(CancellationToken cancellationToken)"
}
}
]
}
Steps to reproduce
https://github.com/glen-84/hc-5893 (.NET 8, HC 13.8.1)
- Create a query using [UseProjection]
- The model that is returned must have a JsonDocument attribute
Relevant log output
No response
Additional Context?
No response
Version
13.0.5
Reacted by Zoë Liebersbach
Metadata
Metadata
Assignees
Labels
Area: DataIssue is related to filtering, sorting, pagination or projectionsArea: Projectionsrepro-validated🌶️ hot chocolate
Activity
[-]JsonDocument problema when using [UseProjection][/-][+]JsonDocument problem when using [UseProjection][/+]michaelstaib commentedon Mar 2, 2023
Your issue needs a repro for us to help you.
alandecastros commentedon Mar 2, 2023
Sure @michaelstaib ! Thanks for the fast response.
This works
Correct output
This does not work
I get the following error:
michaelstaib commentedon Mar 3, 2023
Is ef core able to project json documents like that?
alandecastros commentedon Mar 3, 2023
@michaelstaib I've just tested this out:
And it works fine in EF Core.
glen-84 commentedon Jan 14, 2024
@alandecastros Your repro is incomplete – which DB provider are you using?
alandecastros commentedon Jan 15, 2024
@glen-84 I've just made a more complete repro using HotChocolate 13.8.1
Packages
HotChocolate.AspNetCore 13.8.1
HotChocolate.Data.EntityFramework 13.8.1
Npgsql.EntityFrameworkCore.PostgreSQL 8.0.0
Queries & results
Query that works (without UseProjection)
Query that does not work (using UseProjection)
When calling the second query HotChocolate doesn't even send an SQL to the database.
Regards
glen-84 commentedon Jan 15, 2024
Thanks, I've added a link to a minimal reproduction under the
Steps to reproducesection in the initial comment.