Skip to content

Commit c85d114

Browse files
Vincent MoliniéSeyZ
authored andcommitted
Fix relationshipLinks on nested relationship
1 parent 89272c8 commit c85d114

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

lib/serializer-utils.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,13 @@ module.exports = function (collectionName, record, payload, opts) {
191191
var includedAttrs = [];
192192

193193
if (opts.attributes) {
194+
if (dest) {
195+
opts.attributes.forEach(function (attr) {
196+
if (opts[attr] && !dest[attr] && opts[attr].nullIfMissing) {
197+
dest[attr] = null;
198+
}
199+
});
200+
}
194201
relationships = opts.attributes.filter(function (attr) {
195202
return opts[attr];
196203
});
@@ -204,7 +211,7 @@ module.exports = function (collectionName, record, payload, opts) {
204211
if (includedAttrs) { included.attributes = pick(dest, includedAttrs); }
205212

206213
relationships.forEach(function (relationship) {
207-
if (dest && isComplexType(dest[relationship])) {
214+
if (dest && (isComplexType(dest[relationship]) || dest[relationship] === null)) {
208215
that.serialize(included, dest, relationship, opts[relationship]);
209216
}
210217
});

0 commit comments

Comments
 (0)