jsonapi-serializer icon indicating copy to clipboard operation
jsonapi-serializer copied to clipboard

serialize relationship links without data

Open luxzeitlos opened this issue 6 years ago • 0 comments

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' }
    }
  }
}

luxzeitlos avatar Feb 20 '19 07:02 luxzeitlos