Skip to content

Commit

Permalink
feat: Auto-detect end of pagination
Browse files Browse the repository at this point in the history
  • Loading branch information
edgarrmondragon committed Nov 17, 2023
1 parent 80e31a2 commit 7a2fbf7
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion singer_sdk/streams/rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,14 @@ def request_records(self, context: dict | None) -> t.Iterable[dict]:
resp = decorated_request(prepared_request, context)
request_counter.increment()
self.update_sync_costs(prepared_request, resp, context)
yield from self.parse_response(resp)
records = iter(self.parse_response(resp))
try:
first_record = next(records)
except StopIteration:
self.logger.info("No records found in response")
break
yield first_record
yield from records

paginator.advance(resp)

Expand Down

0 comments on commit 7a2fbf7

Please sign in to comment.