json-api
json-api copied to clipboard
[Issue-69] Adjust relation call for nulled resources
When requesting a nested include such as destination.location for a stop resource, if the stop does not have a destination attached, the request currently fails with an error. This behavior is inconsistent with the JSON:API specification, which requires that missing nullable relationships should return null.
Solution:
Adjusted the resolveRelationships method in the Relationships trait to handle cases where a requested relationship is missing.
Example Behavior After Fix:
Requesting destination.location for a stop without a destination will return:
"relationships": {
"destination": {
"data": null
}
}