I noticed this issue with includes, which it turns out an existing test was already replicating, although there were no asserts in that test, so it wasn't getting caught.
Basically, if multiple different items in the response are all related to the same related resource, then that resource will show up multiple times in the included array.
In certain scenarios, this can cause response sizes to balloon pretty dramatically. In an example in my own application, I was including across a belongs_to and a has_many, and the response had ~30k elements in the includes, but after collapsing down to unique elements, there are actually only ~2100 unique elements.
The solution here is to get unique values by type + id in the includes list, while merging linkages from the distinct elements.
I noticed this issue with includes, which it turns out an existing test was already replicating, although there were no asserts in that test, so it wasn't getting caught.
Basically, if multiple different items in the response are all related to the same related resource, then that resource will show up multiple times in the
included
array.In certain scenarios, this can cause response sizes to balloon pretty dramatically. In an example in my own application, I was including across a
belongs_to
and ahas_many
, and the response had ~30k elements in theincludes
, but after collapsing down to unique elements, there are actually only ~2100 unique elements.The solution here is to get unique values by type + id in the includes list, while merging linkages from the distinct elements.
Contributor checklist