One Way vs. Two Way @hasInverse

Hi,
Your first schema is valid. You can have all type of relationships. By having Person.hasPosts <-> Post.author , we can have posts which refer to author and author which refer to post. It gives you way to add links by both directions, there may be some use case of it though there is no harm if you use only one way @hasinverse.
I am not sure what you will get from

friends: [Person] @hasInverse(field: friends)
Because , i guess functionality will be same if we only have `friends: [Person] , i need to check though.

For the second schema author and editor can’t have @hasInverse(editablePost) at the same time.
But you can have author: User! @hasInverse(field: editablePost, field: myPosts) .

The reason for this is that in first case if we enter any value in editpost then it should be reflected in both author and editor, they will have some duplicate values for all authors/editors which link to User.
Also there can be other problems in that case.

If you need this type of relationship share your detailed schema , we will look into it and find a wayout.
And for second case it’s valid because edipost/mypost can refer to author and there is no harm in that.

1 Like