You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This problem is similar to the one described in issue #125. In this case, the program panics when a relationship is defined with multiple resource types. I've forked @tanmayambre's test repository and fixed it up to reproduce the issue. It's available at https://github.com/mkaminski1988/testapi2go.
Let's say I want to define an Author with a relationship named works that contains types books and blogs. The JSON API output would resemble the following:
It seems that this is caused by the fact that api2go generates all the relationship routes by looping over the references returned by GetReferences(), which may contain duplicate Name fields. The routine that generates routes should work off of a de-duped list of relationship names in order to avoid duplicate routes. I have not found a restriction in the JSON API spec that disallows multiple types in a relationship, so this functionality should be supported.
The text was updated successfully, but these errors were encountered:
you are correct.
Two identical names in get reference ids currently crashes api2go. I haven't looked further into this issue yet, but it is definitely an interesting point.
Was this fixed? I came upon a similar problem, but with to-one heterogeneous relationships. For example, let us say the author has a mostPraisedWork that can be either a book or a blog: this confuses api2go, which fails to call methods of the right structure. It may be a different instance of the same bug, so I am not sure whether I should open a new issue.
This problem is similar to the one described in issue #125. In this case, the program panics when a relationship is defined with multiple resource types. I've forked @tanmayambre's test repository and fixed it up to reproduce the issue. It's available at https://github.com/mkaminski1988/testapi2go.
Let's say I want to define an Author with a relationship named
works
that contains typesbooks
andblogs
. The JSON API output would resemble the following:Here's how I tried to set up the
GetReferences()
function for the author model type:The following error is produced:
It seems that this is caused by the fact that api2go generates all the relationship routes by looping over the references returned by
GetReferences()
, which may contain duplicateName
fields. The routine that generates routes should work off of a de-duped list of relationship names in order to avoid duplicate routes. I have not found a restriction in the JSON API spec that disallows multiple types in a relationship, so this functionality should be supported.The text was updated successfully, but these errors were encountered: