Skip to content

Commit

Permalink
Pass lid from relationship data to get record data
Browse files Browse the repository at this point in the history
The issue appeared in a sideposting scenario:
- model A has has many relationship to model B.

- instance of model A and instance of model B are created on the client,

- model A is saved along with model B sent in `include` section of
  payload; the linking is done through `lid`

- server persisted both models and sent the esponse wih server-generated
  `id` along with `lid` sent by the client.

- when hasMany.updateData() was called while the response payload was
  pushed to the store it couldn't match the record which was already in
  the store with the record data contained in the relationship data
  because `lid` was omitted.
  • Loading branch information
andreyfel committed Oct 6, 2020
1 parent bb839b3 commit 856f6eb
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,11 @@ export default class ManyRelationship extends Relationship {
} else {
recordDatas = new Array(data.length);
for (let i = 0; i < data.length; i++) {
recordDatas[i] = this.recordData.storeWrapper.recordDataFor(data[i].type, data[i].id) as RelationshipRecordData;
recordDatas[i] = this.recordData.storeWrapper.recordDataFor(
data[i].type,
data[i].id,
data[i].lid
) as RelationshipRecordData;
}
}
this.updateRecordDatasFromAdapter(recordDatas);
Expand Down

0 comments on commit 856f6eb

Please sign in to comment.