JSON:API Include can break some JSON:API deserializers by not including the attributes or relationships structure

Created on 10 July 2024, 5 months ago

Problem/Motivation

JSON:API Include currently flattens the entire structure of a JSON:API response as much as possible. In most cases, this results in the removal of the attributes and relationships key.

Under certain circumstances, Javascript based JSON deserializers may ignore flattened data since it is not accounted for or not 'to spec' with expected responses. JSONA, used by default by NextJS for Drupal, is one such case:

https://github.com/olosegres/jsona/blob/master/src/builders/JsonDeserial...

With attributes and relationships removed by JSON:API this data is removed from the end client (NextJS) and cannot be parsed.

Proposed resolution

Don't remove the attributes and relationship keys, but add the included result into their respective keys. This will result in not breaking downstream deserializers or require developers to write their own interpreter add on to account for that.

User interface changes

Potentially introduce configuration for users to decide if it should flatten the array as far as it can, or not.

API changes

Data model changes

🐛 Bug report
Status

Active

Version

1.7

Component

Code

Created by

🇺🇸United States kevinquillen

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024