aribouius / jsonapi-react

A minimal JSON:API client and React hooks for fetching, updating, and caching remote data.
MIT License
149 stars 28 forks source link

Add a "type" property for each item in the normalized data #10

Closed paul-querol closed 4 years ago

paul-querol commented 4 years ago

In cases where multiple document types can be returned and included for one relationship, it's currently difficult to see what data type a document has if it can be one of many without checking for the presence or absence of specific fields which would be brittle.

aribouius commented 4 years ago

Closing in favor of https://github.com/aribouius/jsonapi-react/pull/11

paul-querol commented 3 years ago

Hi @aribouius,

I know this was closed in favour of #11 but would you reconsider including it as well. The other commit ultimately should achieve the same goal but the implementor has a lot more working out to do to get there.

In cases where a developer needs to process a number of different item types on a single relationship which is a common requirement if people are building a page where a number of arbitrary section types that are compiled as a list, the raw data makes it easy to see what each section is and select the appropriate component to render it but that type information is effectively stripped from the normalised data.