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

Add pagination support for balances endpoint on GraphQL #2032

Closed
arboleya opened this issue Jul 10, 2024 · 1 comment · Fixed by #2490
Closed

Add pagination support for balances endpoint on GraphQL #2032

arboleya opened this issue Jul 10, 2024 · 1 comment · Fixed by #2490
Assignees
Labels
enhancement New feature or request

Comments

@arboleya
Copy link
Member

In short, it should provide the same functionality we have for coins, messages, etc.

@rafal-ch
Copy link
Contributor

Rough notes on the scope, subject to change:

  1. add "balances cache" table which would cache the balances in order to provide quick response
  2. figure out how to initialize this table after it comes to existence
    1. in one go, at startup (could lead to downtime)
    2. in the background (start the process, until it is finished respond using the "old way", once finished, switch to responding using the table)
    3. lazy? - calculate balance and store in the "balances cache" table upon request
  3. the table needs to be updated on each operation that changes the balance

Other considerations:

  1. state rewind
  2. off-chain workerm how to sync it with background migration?

AurelienFT added a commit that referenced this issue Jan 15, 2025
Closes [#2023](#2032)
Closes #2496

## TODO:
* [X] Add integration test due to custom logic related to base asset id
* [X] Make it work properly with base asset id

## Description
This PR enables the paginated queries for balances, but only if the
balance indexation is enabled. Otherwise, the attempt to send paginated
query will result with `Can not use pagination when balances indexation
is not available` error.

Additionally, if the balances indexation is available the default query
cost for "balances" will be set to 0, and the complexity will be
calculated based on the amount of items requested. When indexation is
not available, the default query cost stays intact (40001).

## Checklist
- [X] New behavior is reflected in tests

### Before requesting review
- [X] I have reviewed the code myself

---------

Co-authored-by: Green Baneling <[email protected]>
Co-authored-by: AurelienFT <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants