In one of my apps using jsonapi-datastore I needed a way to include to result of serialize method an array of complete relationship objects, just like in jsonapi specification. For my purposes, I created this: mklocek/jsonapi-datastore@a955efec9ecaba87a0dde0598232d1822022df3a. Including is optional here and looks like that:
var projectAttributes = {
attributes: ['title'],
relationships: ['clients', 'managers'],
included: {
clients: {
attributes: ['name']
},
managers: {
attributes: ['name']
}
}
};
project.serialize(projectAttributes);
=> # jsonapi json containing 'included' array
Have you thought about such feature?