From 2bab2eeb9b13ca527bdbccaad95cf8f792acb3bd Mon Sep 17 00:00:00 2001 From: Prathamesh Musale Date: Thu, 29 Aug 2024 18:47:46 +0530 Subject: [PATCH] Disable default pagination --- gql/resolver.go | 26 ++++++++++++++++++++------ x/registry/keeper/query_server.go | 7 ++++++- 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/gql/resolver.go b/gql/resolver.go index 4216470b..7f7e1f01 100644 --- a/gql/resolver.go +++ b/gql/resolver.go @@ -24,6 +24,9 @@ const DefaultLogNumLines = 50 // MaxLogNumLines is the max number of log lines that can be tailed. const MaxLogNumLines = 1000 +// Whether to use default page limit when pagination args are not passed. +const UseDefaultPagination = false + type Resolver struct { ctx client.Context logFile string @@ -140,12 +143,23 @@ func (q queryResolver) LookupNames(ctx context.Context, names []string) ([]*Name func (q queryResolver) QueryRecords(ctx context.Context, attributes []*KeyValueInput, all *bool, limit *int, offset *int) ([]*Record, error) { nsQueryClient := registrytypes.NewQueryClient(q.ctx) - pagination := &query.PageRequest{} - if limit != nil { - pagination.Limit = uint64(*limit) - } - if offset != nil { - pagination.Offset = uint64(*offset) + var pagination *query.PageRequest + + // Use defaults only if limit and offset not provided + // and UseDefaultPagination is true + if limit == nil && offset == nil { + if UseDefaultPagination { + pagination = &query.PageRequest{} + } + } else { + pagination = &query.PageRequest{} + + if limit != nil { + pagination.Limit = uint64(*limit) + } + if offset != nil { + pagination.Offset = uint64(*offset) + } } res, err := nsQueryClient.Records( diff --git a/x/registry/keeper/query_server.go b/x/registry/keeper/query_server.go index 5bee250f..f978ceaa 100644 --- a/x/registry/keeper/query_server.go +++ b/x/registry/keeper/query_server.go @@ -48,7 +48,12 @@ func (qs queryServer) Records(c context.Context, req *registrytypes.QueryRecords return nil, err } } else { - records, pageResp, err = qs.k.PaginatedListRecords(ctx, req.Pagination) + if req.Pagination != nil { + records, pageResp, err = qs.k.PaginatedListRecords(ctx, req.Pagination) + } else { + records, err = qs.k.ListRecords(ctx) + } + if err != nil { return nil, err }