mathematic-inc / ts-japi

A highly-modular (typescript-friendly)-framework agnostic library for serializing data to the JSON:API specification
Apache License 2.0
202 stars 15 forks source link

[BUG] Reciprocal relationships can cause runtime dependency issues #62

Closed egmacke closed 1 year ago

egmacke commented 1 year ago

Describe the bug*

In the case where ModelA has a relationship to ModelB and ModelB also relates back to ModelA it is possible to end up in a runtime state where relators are being built before the model serialisers are available.

To Reproduce*

To simulate this, create 2 model files that define model, serializer and relator, then try to run.

Expected behaviour*

Currently this is expected behaviour, however it makes development with reciprocal relationships very difficult.

I would suggest that by making the model serializer in relators a getter rather than a concrete instance we could mitigate this limitation.