SyneticNL / Hyral

Hypermedia oriented Resource API Layer
MIT License
34 stars 2 forks source link

normalizePaging for jsonApi is not working as expected. #118

Open jurcello opened 5 years ago

jurcello commented 5 years ago
const numPages = parseInt(query.page.number, 10);
const numPerPage = parseInt(query.page.size, 10);

It tries to read the paging using the page query parameter, but jsonAPI returns page[offset] and page[limit]

mnugter commented 5 years ago

Not always! JSON:API standard describes both actually. Any fix should be able to handle both situations.

jurcello commented 5 years ago

That's a good one. In that case we should write a dedicated parser for the Drupal one, because at the moment it fails at parsing the paging information for Drupal.

Maybe the best way to do this is to define parsers for both situations and let another function detect which parser to use.

StevenButeneers commented 5 years ago

In fact JSON:API is agnostic about the pagination strategy that is used by an API (server). Well know strategies include page, offset and cursor based, but are not limited to them.

I.m.o we should allow the client to specify which strategy Hyral should use.