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
In my backend I have a conversation model that olds a foreign_key to the last sent message in that conversation. If there is no last message, this normaliser fails.
The problem does not come from the empty included field. Look at your last_message in your example: "relationships":{ "last_message":{ "data":null } }
the data field here must not be null. It has to be something of this sort { "type": "people", "id": "9" }
The reason it crashes on line 53 is because the data field does not have type subfield.
This is required by the JSON::API specification. If you don't have a last_massage relation, modify your API so that it doesn't respond with a null value.
Thank you very much for your contribution. I will review it and I will post a comment here at a later date.
I'm using https://github.com/Netflix/fast_jsonapi and it's not directly compatible with this lib without making some backend changes. Basically, if a model has a relationship and it's empty (by empty I mean it's null), fast_jsonapi serializes it to null.
Activity
SinestroWhite commentedon Oct 20, 2019
The problem does not come from the empty included field. Look at your last_message in your example:
"relationships":{ "last_message":{ "data":null } }the data field here must not be null. It has to be something of this sort
{ "type": "people", "id": "9" }The reason it crashes on line 53 is because the data field does not have type subfield.
This is required by the JSON::API specification. If you don't have a last_massage relation, modify your API so that it doesn't respond with a null value.
Thank you very much for your contribution. I will review it and I will post a comment here at a later date.
andrepcg commentedon Oct 20, 2019
I'm using https://github.com/Netflix/fast_jsonapi and it's not directly compatible with this lib without making some backend changes. Basically, if a model has a relationship and it's empty (by empty I mean it's null),
fast_jsonapiserializes it tonull.SinestroWhite commentedon Oct 20, 2019
Yeah, I got it and you are right that a null value must not give an error.