Include requested entities in returned JSON when using a complex prefetch~json parameter
Given the following query string: /artists?prefetch~json={"cds":"tracks"} I would expect a response similar to this:
{
"linked": {
"cds": [...],
"tracks": [...],
},
"links": {
"cds": {...},
"tracks": {...}
},
"artists": [...]
}
But I am instead getting this, without tracks in the results:
{
"linked": {
"cds": [...],
},
"links": {
"cds": {...},
},
"artists": [...]
}
That seems covered by an existing test that appears to produce what you're looking for. Could you try reproducing the problem in the WPID test suite?
@timbunce Thats not actually an example of the type of prefetch asked in the OP. see https://github.com/timbunce/WebAPI-DBIC/blob/master/t/media-jsonapi/40-prefetch-req.exp#L399-L421 for the test. Though this output doesn't even look remotely correct.
I am not sure how JSON-API output should look for this sort of nested prefetch. The HALJSON format tests however outputs correctly.
Oh, right. Thanks @ungrim97! I'd only taken a quick look and was read the prefetch like it was a simple comma list.
This is likely caused by Result class TestSchema::Result::CD_to_Producer has has multiple keys so relations like cd_to_producer won't have links generated.
@lohengrin332 this is a better example of a complex prefetch that seems to be doing the right thing.
@timbunce Based on the prefetch supplied and the response shown by the application/hal+json format, I would expect the cd_to_producer and producer to be returned in the response.
Is this therefor a limitation of application/api+json?