KnpLabs/php-github-api

Autoload pagination results

buismaarten opened this issue · 4 comments

I know this has been asked before a couple of years ago. Is there a way to autoload all results automatically using the Github pagination links?

I think the best option is to add a global configuration option to leave it up to the user.

@buismaarten If I understand your question correctly the ResultPager class and the fetchAll method is what you are looking for.

Not exactly, the fetchAll method on the ResultPager class feels very verbose and not very intuitive. Is there a way to autoload all results automatically using the Github pagination links?

Changes in code are definitively needed, but making thing so much easier.

Can you explain a bit more what is wrong with this method or provide some example illustrate the problem? Because the ResultPager::fetchAll actually uses the pagination links returned by the api endpoint to fetch all results (it loops interally over these pagination links) and with just calling the method the get the full result array returned.

And If you use ResultPager:: fetchAllLazy the method will return a generator to reduce the amount of memory used the fetch all results.

It's just my opinion, but it doesn't feel right to specify the method name as a string using the second argument of fetchAllLazy or fetchAll.

With the current design it is impossible to use $github->user()->repositories('acrobat') to get all the results from the api using the GitHub pagination.

With a configuration option inside the Github\Client class it is up to the user to enable of disable the functionality to autoload all the results.