kamikat / moshi-jsonapi

JSON API v1.0 Specification in Moshi.
MIT License
156 stars 34 forks source link

Separate Document From Resource #34

Closed lukesleeman closed 7 years ago

lukesleeman commented 7 years ago

We have found the current model, where there is a bidirectional link between Resource and Document to be very limiting and would like to open up a discussion about removing the link from Resources back to their parent document. We understand that this would be a fairly considerable design change - perhaps this something best targeted at moshi-jsonapi 3.0

Currently a Document stores its data and included resources and each Resource has a (nullable) link back to the Document that contains it via the _doc field. The link from Resource to Document is used to resolve HasOne and HasMany. This link from Resource to Document has caused us number of issues:

Removing the link from Resource to Document will be tricky - in particular it will require a solution for HasOne and HasMany which currently look up their values from the resources Document. I hope with this issue to prompt some discussion of ways to solve some of these issues.

kamikat commented 7 years ago

Thanks for your advice. With changes made in 3.x, we're now have Document and Resource less coupling. Serialization/deserialization now starts from a document and ends with a document, that is, a more consistent and less astonishing interface. But I can't make sure if the new version meets your requirement.