Open SamMarkGoldman opened 6 years ago
I can confirm this issue exists in 0.9.10
specifically in processing the include
only polymorphic
are taken into consideration
https://github.com/cerebris/jsonapi-resources/blob/v0.9.10/lib/jsonapi/resource.rb#L1283-L1288
so as as a workaround setting polymorphic: true
actually works even if the has_one
relationship to a non-AR backed resource and the resource is included non-eagerly.
This issue is a (choose one):
Checklist before submitting:
Description
It seems that dynamic related resources, a feature we use heavily here at Blue Apron, is broken coming from
v0.8.0
tov0.9.0
. It looks like in the older version, related resources which don't provide a foreign key in the owner model resolved by calling a method on that model with the related resource's name. This same behavior is part of the active record convention: https://github.com/cerebris/jsonapi-resources/blob/v0.8.0/lib/jsonapi/resource_serializer.rb#L301However in the new version (
v0.9.0
), this functionality is no longer supported in theToOne
relationship child class: https://github.com/cerebris/jsonapi-resources/blob/854ec705183d744565106cf34b12a741139d157e/lib/jsonapi/relationship.rb#L89 Instead, relationships are based on the assumption that related resources are datastore backed, and use foreign keys rather than methods to relate to one another.The below test passes when specifying the older version of the library, and fails when specifying the newer version. The example is stripped down (and thus a little contrived), but I assure you one can support JSONAPI compliant resources using this method.
Bug reports: