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

request: paginate the response of getAllPokemon to allow for further nesting of data #900

Open
1 task done
favna opened this issue Dec 15, 2023 · 0 comments
Open
1 task done

Comments

@favna
Copy link
Member

favna commented Dec 15, 2023

Is there an existing issue or pull request for this?

  • I have searched the existing issues and pull requests

Feature description

Currently the response of getAllPokemon is, by default, not paginated. This sets a hard limit on how much data can be returned defined by the string limit that the v8 engine can handle (~1GB). At the time of writing (2023-15-12) with the data from Scarlet & Violet Indigo Disk the full JSON is ~524 MB. This size will ever only increase as time goes on and more Pokémon are released. Furthermore, this limit also blocks the expansion of further nesting data, such as changing otherFormes to be proper Pokemon references as opposed to just species strings.

Important

This change would be a breaking change because the response of getAllPokemon would drastically change.

Desired solution

To resolve this issue the response from getAllPokemon should be paginated by default. The following rules will be applied:

  • If no pagination options are provided by the user the default amount per page of 250 is used
  • Input validation will ensure the user can never request more than 250 Pokémon per page
  • The following interface will be used for a paged response:
interface PaginatedResponse {
  data: TheOldDataObject;
  totalCount: number; // The total count of results
  pages: number; // The total amount of pages based on taken and totalCount
  page: number; // The current page number
  offsetForCurrentPage: number; // The offset provided for this request
  offsetNextPage: number; // The offset to provide to jump to the next page
  taken: number; // The amount taken (length of data)
}

Alternatives considered

  • Migrating to a different programming language than TypeScript that doesn't have the 1GB limit that v8 does. This however is only delaying the inevitable because at some point any programming language is going to run out of space.

Additional context

#899 where otherFormes nesting was added as an attempt to provide more data to the end-user

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

No branches or pull requests

1 participant