digitalsadhu / loopback-component-jsonapi

JSONAPI support for loopback.
MIT License
101 stars 32 forks source link

fix(deserializer): Unable to create polymorphic relationship #298 #299

Open grahambates opened 5 years ago

grahambates commented 5 years ago

Adds polymorphic support for belongsTo relationships.

digitalsadhu commented 5 years ago

Thanks for the PR @grahambates ! Looks like theres a small lint error to get the tests passing

coveralls commented 5 years ago

Coverage Status

Coverage decreased (-0.9%) to 93.643% when pulling 94c439db7527ac1298061f7c8a16876175fe149a on grahambates:master into 40f928273fe50acfebb11cbaf2e0469f0d56efea on digitalsadhu:master.

coveralls commented 5 years ago

Coverage Status

Coverage increased (+0.08%) to 94.634% when pulling be3ab33509dba9117d583296cd9fb2bc049bc6e3 on grahambates:master into a7083aad413b3404bc1466650b20b6437983133a on digitalsadhu:master.

grahambates commented 5 years ago

I've fixed the lint errors and added some tests.

The failing check is due to use of the spread operator in a dependency (strong-globalize) which breaks compatibility with node 4. This is obviously unreleated to the change.

grahambates commented 5 years ago

In getting my tests to work I've also fixed an issue where the serializer did not handle optional polymorphic belongsTo relationships. It would trigger an error where the discriminator value was empty because the relationship was not set. I've added a test case for this too.