denali-js / core

An opinionated, ORM agnostic framework for building robust JSON APIs in Node
http://denalijs.org
Apache License 2.0
73 stars 14 forks source link

when `getRelated` for a `hasOne` relationship returns `null` it throws #436

Open luxzeitlos opened 6 years ago

luxzeitlos commented 6 years ago

Cannot read property ‘modelName’ of null

It does this here where denali assumes that relatedRecord may not be null, which is not true.

however I think the fundamental problem is a wrong type definition here, where getRelated may not return null. If we add null there I think typescript would have saved us from that.

Same is true for the adapter here where any seems dangerous.