Skip to content

Commit 3351615

Browse files
committed
fix: linkName from decorator assign value to the correct property
1 parent ee7e835 commit 3351615

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

src/app/core/cache/builders/link.service.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,16 @@ export class LinkService {
112112
* @param linkToFollow the {@link FollowLinkConfig} to resolve
113113
*/
114114
public resolveLink<T extends HALResource>(model, linkToFollow: FollowLinkConfig<T>): T {
115-
model[linkToFollow.name] = this.resolveLinkWithoutAttaching(model, linkToFollow);
115+
const linkDefinitions = this.getLinkDefinitions(model.constructor as GenericConstructor<T>);
116+
const linkDef = linkDefinitions.get(linkToFollow.name);
117+
118+
if (isNotEmpty(linkDef)) {
119+
// If link exist in definition we can resolve it and use a real property name
120+
model[linkDef.propertyName] = this.resolveLinkWithoutAttaching(model, linkToFollow);
121+
} else {
122+
// For some links we don't have a definition, so we use the link name as property name
123+
model[linkToFollow.name] = this.resolveLinkWithoutAttaching(model, linkToFollow);
124+
}
116125
return model;
117126
}
118127

0 commit comments

Comments
 (0)