tobyzerner / json-api-php

JSON-API (http://jsonapi.org) responses in PHP.
MIT License
436 stars 79 forks source link

Empty Relation #57

Closed vinkla closed 9 years ago

vinkla commented 9 years ago

Currently (0.1.1) the package throws an error if the relation the client is trying to include a relation doesn't exist. What is expected behaviour? Should it throw an error?

return new Relation($resource); // throws and error if $resource is null

Maybe this should just return empty instead?

tobyzerner commented 9 years ago

You should only create a Relationship object if there is relationship data – otherwise just return null. I don't think this is an issue in the 0.2 branch because the Builder automatically checks this for you.

vinkla commented 9 years ago

That's great. Thanks.