loopback-component-jsonapi icon indicating copy to clipboard operation
loopback-component-jsonapi copied to clipboard

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

Open grahambates opened this issue 5 years ago • 5 comments

Adds polymorphic support for belongsTo relationships.

grahambates avatar Jan 15 '19 13:01 grahambates

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

digitalsadhu avatar Jan 16 '19 20:01 digitalsadhu

Coverage Status

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

coveralls avatar Jan 16 '19 21:01 coveralls

Coverage Status

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

coveralls avatar Jan 16 '19 21:01 coveralls

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 avatar Jan 16 '19 22:01 grahambates

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.

grahambates avatar Jan 16 '19 23:01 grahambates