Skip to content

Commit

Permalink
feat: preserve lids returned by the API in legacy normalization (#9401)
Browse files Browse the repository at this point in the history
  • Loading branch information
runspired authored May 11, 2024
1 parent b9729ed commit 7068003
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
7 changes: 7 additions & 0 deletions packages/serializer/src/-private/embedded-records-mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,9 @@ export default Mixin.create({
}

hasMany[i] = { id: data.id, type: data.type };
if (data.lid) {
hasMany[i].lid = data.lid;
}
}

const relationship = { data: hasMany };
Expand All @@ -611,6 +614,10 @@ export default Mixin.create({
const belongsTo = { id: data.id, type: data.type };
const relationship = { data: belongsTo };

if (data.lid) {
belongsTo.lid = data.lid;
}

hash.data.relationships[key] = relationship;
},

Expand Down
4 changes: 4 additions & 0 deletions packages/serializer/src/json.js
Original file line number Diff line number Diff line change
Expand Up @@ -617,6 +617,10 @@ const JSONSerializer = Serializer.extend({
relationships: this.extractRelationships(modelClass, resourceHash),
};

if (resourceHash.lid) {
data.lid = resourceHash.lid;
}

this.applyTransforms(modelClass, data.attributes);
}

Expand Down

0 comments on commit 7068003

Please sign in to comment.