jsonapi-serializer
jsonapi-serializer copied to clipboard
serialize relationship links without data
This is basically a dup of #34.
Currently if the relationships are missing links also wont be serialized. However there is nullIfMissing. Basically we would need a linksIfMissing or (in my opinion better) default to this. The current behaviour that links get removed when there is no data is unexpected.
So I have this input data:
{ id: 1 }
This options:
{
attributes: ['comments'],
comments: {
ref: 'id',
nullIfMissing: false,
ignoreRelationshipData: false,
relationshipLinks: {
related: () => `/related`,
}
}
}
and expect this output:
{
data: {
id: '1',
relationships: {
comments: {
links: { related: '/related' }
}
}
}