Skip to content
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

Async iterator pagination #157

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

Conversation

aspilchen
Copy link
Contributor

Thank you for helping out! ✨

We really appreciate your commitment to improving Architect

To maintain a high standard of quality in our releases, before merging every pull request we ask that you've completed the following:

  • Forked the repo and created your branch from master
  • Made sure tests pass (run npm it from the repo root)
  • Expanded test coverage related to your changes:
    • Added and/or updated unit tests (if appropriate)
    • Added and/or updated integration tests (if appropriate)
  • Updated relevant documentation:
  • Summarized your changes in changelog.md
  • Linked to any related issues, PRs, etc. below that may relate to, consume, or necessitate these changes

Please also be sure to completed the CLA (if you haven't already).

Learn more about contributing to Architect here.

Thanks again!

@aspilchen
Copy link
Contributor Author

aspilchen commented Jun 29, 2024

TODO:

  • Handle errors

Extra notes:

  • Current version requires paginate param to be a string, plugin validation enforces bool

@aspilchen aspilchen linked an issue Jun 29, 2024 that may be closed by this pull request
aspilchen and others added 2 commits June 30, 2024 17:40
Enable iterative pagination in raw client
Improve iterator error handling
Copy link
Contributor Author

@aspilchen aspilchen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (foundNestedToken && (foundNestedToken !== params[type][cursor[i]])) {

Throws error if params[type] does not exist

request = server.getCurrentRequest()
expectedUrl = '/?Cursor=t1'
t.deepEqual(page.value.payload, simpleResponseBodies[1], 'Incorrect response body')
t.equal(request.url, expectedUrl, 'Response token does not match next request cursor')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All of these tests notate "incorrect..." or "does not match..." when a passing test would be correct, or match, etc. As a reminder, the third argument in most of these tape methods is the description of the test in question.


// Query type, no more pages
page = await response.next()
t.true(page.done, 'Iterator not done when it ought to be')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer t.ok

@ryanblock
Copy link
Member

if (foundNestedToken && (foundNestedToken !== params[type][cursor[i]])) {

Throws error if params[type] does not exist

Got it, interesting this hasn't come up, but that's why unit tests are nice. :)

I'm thinking if params[type] then perhaps we need to backfill it earlier in execution, like params[type] = params[type] || {}?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Multiple Pagination Accumulators
2 participants