Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUGFIX links] relationship setup for link fetch should batch #6586

Merged
merged 4 commits into from
Oct 20, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 20 additions & 16 deletions packages/store/addon/-private/system/core-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1634,14 +1634,16 @@ abstract class CoreStore extends Service {
if (shouldFindViaLink) {
return this.findHasMany(parentInternalModel, resource.links.related, relationshipMeta, options).then(
internalModels => {
let payload: { data: any[]; meta?: any } = {
data: internalModels.map(im => (recordDataFor(im) as RelationshipRecordData).getResourceIdentifier()),
};
if (internalModels.meta !== undefined) {
payload.meta = internalModels.meta;
}
parentInternalModel.linkWasLoadedForRelationship(relationshipMeta.key, payload);
return internalModels;
this._backburner.join(() => {
runspired marked this conversation as resolved.
Show resolved Hide resolved
let payload: { data: any[]; meta?: any } = {
data: internalModels.map(im => (recordDataFor(im) as RelationshipRecordData).getResourceIdentifier()),
};
if (internalModels.meta !== undefined) {
payload.meta = internalModels.meta;
}
parentInternalModel.linkWasLoadedForRelationship(relationshipMeta.key, payload);
return internalModels;
});
}
);
}
Expand Down Expand Up @@ -1713,14 +1715,16 @@ abstract class CoreStore extends Service {
}
return this.findBelongsTo(parentInternalModel, resource.links.related, relationshipMeta, options).then(
internalModel => {
let response =
internalModel && (recordDataFor(internalModel) as RelationshipRecordData).getResourceIdentifier();
parentInternalModel.linkWasLoadedForRelationship(relationshipMeta.key, { data: response });
if (internalModel === null) {
return null;
}
// TODO Igor this doesn't seem like the right boundary, probably the caller method should extract the record out
return internalModel.getRecord();
return this._backburner.join(() => {
let response = internalModel && (recordDataFor(internalModel) as RelationshipRecordData).getResourceIdentifier();
parentInternalModel.linkWasLoadedForRelationship(relationshipMeta.key, { data: response });
if (internalModel === null) {
return null;
}
// TODO Igor this doesn't seem like the right boundary, probably the caller method should extract the record out
return internalModel.getRecord();
}
);
}
);
}
Expand Down