@mickey Glad to see Perl implementation.
You have bad example in Moreso, fields can be combined with include
. The following response is invalid as according to specification a compound document should be fully linked.
data => [
{ type => "articles", id => 2, },
{ type => "articles", id => 3, },
],
include => [
{
type => 'people', id => 44,
attributes => { name => "Foo" },
},
{
type => 'people', id => 46,
attributes => { name => "Bar" },
}
]
you have the following request:
type => 'articles',
include => [qw/ authors /],
fields => {
articles => [], # no attributes or relationships
people => [qw/ name /],
},
response shouldn’t have any objects included at all as there is no filter[articles][]=authors
argument.
To get more expected response request should have:
type => 'articles',
include => [qw/ authors /],
fields => {
articles => ['authors'],
people => [qw/ name /],
},
And response would be:
data => [
{ type => "articles", id => 2, relationships => { authors => [{type => 'people', id => 44}] } },
{ type => "articles", id => 3, relationships => { authors => [{type => 'people', id => 46}] } },
],
include => [
{
type => 'people', id => 44,
attributes => { name => "Foo" },
},
{
type => 'people', id => 46,
attributes => { name => "Bar" },
}
]
See second note in the following section http://jsonapi.org/format/#fetching-includes