Are relationships implicitly Bi-Directional?


#1

If I have a set of objects that I want to model as only a “has a” relationship, is that the default way of modeling in JSON API, or is creating a relationship implicitly bi-directional?

IE: If an Author “has a” article, does the article “has a” author?

Is there a way to define directionality?

Thanks!


#2

I’d say implicitly yes, but it is not required to be bi-directional - that’s up to your implementation I think.


#3

I’m not 100% sure that I’ve understood the question, but I’d say that there’s no such thing has an implicit bidirectional relationship in the specification.

If users have one book, that doesn’t mean that books have one or many users. If you want books to have an author for example, then you have to explicit make the relationship.


#4

Not directly your scenario, but I’ve realised there is one common case where the relationship is one way - collections.
A collection of resources is represented as an array, each resource in the collection can expose its own URL via the self member of links. (The collection doesn’t expose individual relationships for each member)
But when viewing an individual resource there is no links member that can point back to the collection, instead the resource has to use a memberOf (or similar) relationship to refer to the collection.