Need some help, I’m trying to create a many to many self relation but fauna graphql wont allow me to do it, error: many to many self references are not allowed.
But graphql in essence accepts that, it’s maybe my syntax in fauna that I’m doing wrong
This is what I’m trying to accomplish:
Category object with category children… whose can have more category children.
This is similar to using a tree of category object.
You can create an intermediate “link table” yourself. Fauna creates many-to-many relationships by creating an intermediate Collection and abstracting the implementation out of the way for you. It’s more tedious to do yourself but it is possible.
Side note: some times it is useful to do this yourself anyway in order to add properties to a relationship, or “edge properties” if you can think about it like a graph.
When you create relationships between the parent/child items, you have to create the “links” yourself. Here, I’ve used a nested mutation to create one item and creating a list of children links, each one then creating another item as the child. They are query-able by explicitly selecting all of the links and then selecting the child field of the link.
If you create your own link-table-like Collection, you may want to manually create a unique compound index on the joining fields. This is to ensure that the same link is not made more than once. For this example it could be: