graphql-platform
graphql-platform copied to clipboard
Nested Paging entity Framework
Is there an existing issue for this?
- [X] I have searched the existing issues
Describe the bug
I'm using the entity framework integration and I have tried doing paging on a child collection with annotations
public class Person
{
[GraphQLDescription("Name of the member")]
public string Name { get; set; }
[GraphQLDescription("Things they like")]
[UsePaging]
public ICollection<Interest> Interests { get; set; } = new List<Interest>();
}
which didn't work and I found another issue https://github.com/ChilliCream/hotchocolate/issues/4214 which suggests you cannot get nested paging to work with annotations.
So, I've tried to make a PersonType and define a resolver but it just breaks the schema and the just says encountered an error fetching the schema.
public class PersonType : ObjectType<Person>
{
protected override void Configure(IObjectTypeDescriptor<Person> descriptor)
{
descriptor
.Field(p => p.Name)
.Description("Name of the member");
descriptor
.Field(p => p.Interests)
.UsePaging()
.ResolveWith<Resolvers>(p => p.GetInterests(default!, default!))
.UseDbContext<AppDbContext>()
.Description("Things they like");
}
private class Resolvers
{
public IQueryable<Interest> GetInterests([Parent] Person person, [ScopedService] AppDbContext context)
{
return context.Interests.Where(x => x.PersonId == person.Id);
}
}
}
If I remove the .UsePaging() the collection works but when I add it back the schema breaks and I cant find any docs on how to do paging for a collection within another object?
Steps to reproduce
Use entity framework integration, add child collection to a type apply add paging.
Relevant log output
No response
Additional Context?
No response
Product
Hot Chocolate
Version
12.0.0
What error do you get when you define the type?
The UI says encountered an error fetching the schema but I'm not sure what the error is or how to see it
@PascalSenn I found how to get the schema error which I fixed by .UseDbContext<AppDbContext>() above .UsePaging()
and now it goes back to the same error I got when I was using the annotations which is
Type 'System.Collections.Generic.ICollection`1[App.Interest]' does not have a default constructor (Parameter 'type')
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Have you ever got to the bottom of this issue?
@PascalSenn I found how to get the schema error which I fixed by
.UseDbContext<AppDbContext>()above.UsePaging()and now it goes back to the same error I got when I was using the annotations which is
Type 'System.Collections.Generic.ICollection`1[App.Interest]' does not have a default constructor (Parameter 'type')
@zyofeng nested pagination is currently not projectiable i guess this is the issue
@zyofeng nested pagination is currently not projectiable i guess this is the issue
Not just pagination, UseFirstOrDefault also does not work. I tried opting out of Projection by using IsProjected attribute on the property but that does not seem to have made any difference.
This issue is blocking for our project, any updates on this?
Hello @PascalSenn If I'm not missunderstood, currently is not possible to paginate nested objects with EF data provider?
No news on this? @PascalSenn
Hi, @PascalSenn: Any News ? Thx !
@capitlux @BjornFrierPedersen
While it's not "automatic" projection, the following new concepts are avaialbe in v14: https://www.youtube.com/watch?v=kOGS7HI3lEA