-
Notifications
You must be signed in to change notification settings - Fork 263
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add ListAll methods to resources with ListWithPagination methods #282
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #282 +/- ##
==========================================
Coverage 100.00% 100.00%
==========================================
Files 52 52
Lines 2211 2316 +105
==========================================
+ Hits 2211 2316 +105 ☔ View full report in Codecov by Sentry. |
Thanks for the PR! |
@oliver006 no worries. This is this week's ping. I'll hit you up again in a week if I don't hear from you |
Just catching up here and with #230 so bear with me if I'm a bit slow.
re: backwards compatibility: is your concern that people currently expect I think that makes sense though I wish we could go back and make the change that List() returns all data (like your ListAll() call) and ListWithPagination could be used for more selective access. v4.0 is kinda new - do you think we could still make that kind of change and release it as 4.1 ? |
Exactly, I don't want to be the reason someone was downloading 50 items and is now downloading 5,000 just by updating a dependency
We can, but I'm worried that could be confusing since the pagination was only added to some of the endpoints, so I think the easiest option is to go with this for now, then go through and see what other entities now support pagination (if there have been any additions) and if there is now pagination for all endpoints, introduce that as a breaking change in maybe a 4.2 |
I think what you say makes sense, let's keep ListAll() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR!
@@ -111,6 +112,29 @@ func (s *CustomerServiceOp) List(ctx context.Context, options interface{}) ([]Cu | |||
return resource.Customers, err | |||
} | |||
|
|||
// ListAll Lists all customers, iterating over pages | |||
func (s *CustomerServiceOp) ListAll(ctx context.Context, options interface{}) ([]Customer, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm sorry you had to write this 15 times.
One day I'll get around to redo a large part of this library using generics but today is not that day
(plus it'll break backwards compatibility with slightly older Golang versions)
This relates to #230
It looks like the
List
method only returns the first page for all of the resources that we have aListWithPagination
.I wasn't super comfortable breaking backwards compatibility, so with this PR I'm adding a
ListAll
method that utilizesListWithPagination
to pull all of the items