Hi.
We have found a minor bug with crnk relationship. In a relationship the type specifies which repository to fetch the data from. But in our case the model of repository is a subclass of the object used in the model of the request.
Example:
{ "data": { "type": "human", "attributes": { "name": "Jon Smith" }, "relationships": { "pet": { "data": { "type": "dog", "id": "123" } },"pet": { "data": { "type": "cat", "id": "123" } } } } }
here both "cat" and "dog" are subclasses of "animal". The ID is for dog. Human have
@JsonApiRelation(lookUp = LookupIncludeBehavior.AUTOMATICALLY_ALWAYS) private Animal animal;
it will fail for "cat" as the repository of "dog" will throw "ResourceNotFound". The bug is that if the ID of said object from repository doesn't match the type specified on the relationship but both of them are subclasses in what they are trying to populate.
Shouldn't the relationship type match the object jsonapiresource type?
{ "data": { "type": "human", "attributes": { "name": "Jon Smith" }, "relationships": { "pet": { "data": { "type": "animal", "id": "123" } },"pet": { "data": { "type": "animal", "id": "123" } } } } }
As this is what is specify in Human class?
Thanks,
Chris
Hi.
We have found a minor bug with crnk relationship. In a relationship the type specifies which repository to fetch the data from. But in our case the model of repository is a subclass of the object used in the model of the request.
Example:
{ "data": { "type": "human", "attributes": { "name": "Jon Smith" }, "relationships": { "pet": { "data": { "type": "dog", "id": "123" } },"pet": { "data": { "type": "cat", "id": "123" } } } } }here both "cat" and "dog" are subclasses of "animal". The ID is for dog. Human have
@JsonApiRelation(lookUp = LookupIncludeBehavior.AUTOMATICALLY_ALWAYS) private Animal animal;it will fail for "cat" as the repository of "dog" will throw "ResourceNotFound". The bug is that if the ID of said object from repository doesn't match the type specified on the relationship but both of them are subclasses in what they are trying to populate.
Shouldn't the relationship type match the object jsonapiresource type?
{ "data": { "type": "human", "attributes": { "name": "Jon Smith" }, "relationships": { "pet": { "data": { "type": "animal", "id": "123" } },"pet": { "data": { "type": "animal", "id": "123" } } } } }As this is what is specify in Human class?
Thanks,
Chris