jsonapi-mapper icon indicating copy to clipboard operation
jsonapi-mapper copied to clipboard

Support for page and pageSize in pagination

Open ErisDS opened this issue 9 years ago • 4 comments

The JSONAPI Spec is agnostic about pagination strategies: http://jsonapi.org/format/#fetching-pagination

The default bookshelf plugin supports two strategies: https://github.com/tgriesser/bookshelf/wiki/Plugin:-Pagination

The default uses page and pageSize, although limit and offset can also be used.

It would be great if this library could support both.

Whilst I'm here, I must say that whilst I understand why TypeScript is a good choice for this sort of code, it does create a huge barrier to contributing. I'm testing this library out as a way to get from bookshelf to JSONAPI for a couple of APIs I'm building and I'd love to get stuck in and help but I don't know TypeScript 😞

ErisDS avatar Oct 21 '16 13:10 ErisDS

TypeScript won't normally go against you. Try first thinking your ideas in pseudocode, then ES6 and then the types you're handling. There's many things reasons typescript won't get in your way:

  • It doesn't add custom mandatory syntax. Most ES6 will be 95% compatible.
  • Compilation errors are not blocking, they will still generate (as best as it can) the corresponding Javascript. You will still be able to error-compile and run tests that do pass, for example.
  • We are here! Open a PR and we will be actively looking at the good ideas or the mistakes you make in the way and provide feedback to fix or help you. If we're logged in, you can also find help at our gitter channel
  • If all that fails, the typescript documentation, the typescript book, and the typescript spec are great resources to find answers on your own. The typescript gitter channel too.

ShadowManu avatar Oct 21 '16 16:10 ShadowManu

@ErisDS certainly open to supporting this!

With regards to Typescript: as @ShadowManu alluded to, the transition isn't nearly as daunting as one may think. I'm the original creator of this library and when I had wrote it, it wasn't typescript. After @ShadowManu did the original rewrite in TS, I jumped in and contributed with very few issues caused by TS. In fact, it was fairly simple. I'd suggest you give it a shot and as @ShadowManu mentioned, we're here to help!

jamesdixon avatar Oct 21 '16 19:10 jamesdixon

I appreciate the positive response to what was a moan, however I'm pretty strapped for time 😁 Could you perhaps add a brief getting started guide to the README or contributing.md that covers how to setup, build the repo, and run the tests? A couple of bullet points & commands would be a real help to get over the wall.

ErisDS avatar Oct 25 '16 18:10 ErisDS

Sounds reasonable. I have a little free time for this. EDIT: the contributing page is now added ;)

ShadowManu avatar Oct 25 '16 20:10 ShadowManu