google / jsonapi

jsonapi.org style payload serializer and deserializer
http://godoc.org/github.com/google/jsonapi
MIT License
1.42k stars 210 forks source link

Support for partial inclusion of relationships #177

Open caiotoon opened 5 years ago

caiotoon commented 5 years ago

JSON:API has support for optional inclusion of related objects.

The specification states that in case the request has an explicit include directive, it MUST NOT include unrequested entities.

If an endpoint supports the include parameter and a client supplies it, the server MUST NOT include unrequested resource objects in the included section of the compound document.

The problem is that calling MarshalPayload will include all related items, whereas MarshalPayloadWithoutIncluded includes none.

It does not seem to be possible to support this use case with the current version of the library.