infinum/ngx-hal

getRelationshipUrl function returns undefined if the relationship is not defined on the model

Closed this issue · 1 comments

If the relationship is not defined on the model when calling the getRelationshipUrl function, the function will return undefined even though the link really does exist on the model. The function should return the link if it exists on the model regardless if the relationship is defined on the model or not.

The described behavior is the intended behavior of the getRelationshipUrl method. It is implemented like that to discourage using property names from a raw response in other parts of an app (other than the network layer).

If there is a need to access a relationship URL without defining that relationship on a model, a getter can be used instead, ie.

...
get linkToMysticProperty() {
  return this.links.mystic.href;
}