0

I found the following code in the documentation of hotchocolate at this link

https://chillicream.com/docs/hotchocolate/v13/fetching-data/pagination

 public class QueryType : ObjectType
    {
        protected override void Configure(IObjectTypeDescriptor descriptor)
        {
            descriptor
                .Field("users")
                .UseOffsetPaging()
                .Resolve(context =>
                {
                    var repository = context.Service<IUserRespository>();

                    return repository.GetUsers();
                });
       }
   }

Inspired by the code shown I wrote the following code

 public class QueryType2 : ObjectType
    {
        protected override void Configure(IObjectTypeDescriptor descriptor)
        {
            descriptor
                .Field("seet") // ***
                .Name("seet")                
                //.UseOffsetPaging()                
                //.UseOffsetPaging<IdType>()
                .UseFiltering()
                .UseSorting()
                .Type<ListType<SeetType>>()  
                .Resolve(context =>
                {
                    var dbContext = context.Service<ApplicationDbContext>();
                    return dbContext.Seet.Include(x => x.TypeSeet).AsQueryable();
                });  
        }
    }

    public class SeetType : ObjectType<Seet>
    {
        protected override void Configure(IObjectTypeDescriptor<Seet> descriptor)
        {
            descriptor
                .Field(f => f.SeetId)
                .Type<IntType>();
                //.Type<IdType>();

            descriptor
                .Field(f => f.SeetNumber)
                .Type<StringType>();
                //.Type<IdType>();

            descriptor
                .Field("campo2")
                .Resolve(context =>
                {
                    Console.WriteLine("x");
                    return "valore campo 2";
                });
        }
    }
  1. Now if .UseOffsetPaging() and UseOffsetPaging<IdType>() are commented out it works I can filter and sort

  2. If I enable .UseOffsetPaging() it doesn't work and from the test page it shows nothing

  3. If I enable UseOffsetPaging<IdType>() it partially works and from the test page it shows this, but how do I indicate the fields of the query?

! enter image description here

! enter image description here

How do you make point 2 and 3 work?

I hope I was clear - Many Thanks

I've done several tests but I can't get out of it

Hans Kesting
  • 38,117
  • 9
  • 79
  • 111

0 Answers0