I want to load related records inside "relationships" key
Hi! I'm following the Ash book, specifically on loading related records:
Where I wanted to return the related records (
:albums) of :artist resource and the attributes of :albums are already public.
It returns:
I understand that the related records go in "included": ... key. But what I really wanted is to show the related attributes inside "relationships" key:
5 Replies
is that valid according to the JSON:API spec?
@sevenseacat yes, a valid spec. I trimmed some data in response to make it shorter to read. The
... and <some comments i made> were just me adding comments in this thread, not part of the original api response.reading through https://jsonapi.org/format/#document-compound-documents and it mentions that includes should be done with resource identifier objects in
relationships, and the actual records in included, which is what we have nowGot it. But I'm curious how do I load the public attributes (
:album) in relationships?
My understanding from this is: match the album id in relationships (since the data only contains id and type) to what's inside includedyep yep