Skip to content

Commit

Permalink
Fix ListAll function on types_template.go to depaginate results on co…
Browse files Browse the repository at this point in the history
…llection
  • Loading branch information
rawmind0 committed Feb 11, 2020
1 parent 40f8d46 commit 1e35d1c
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions generator/type_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,14 @@ func (c *{{.schema.CodeName}}Client) ListAll(opts *types.ListOpts) (*{{.schema.C
return resp, err
}
data := resp.Data
for resp, err = resp.Next(); resp != nil && err == nil; resp, err = resp.Next() {
data = append(data, resp.Data...)
for next, err := resp.Next(); next != nil && err == nil; next, err = next.Next() {
data = append(data, next.Data...)
resp = next
resp.Data = data
}
if err != nil {
return resp, err
}
resp.Data = data
return resp, err
}
Expand Down

0 comments on commit 1e35d1c

Please sign in to comment.