jsonapi-suite / jsonapi_compliable

MIT License
20 stars 35 forks source link

Ensure has_one artificially limits #91

Closed richmolj closed 6 years ago

richmolj commented 6 years ago

We don't want to limit(1) a has_one. If a Post has_one Detail, and we were listing all posts and sideloading their detail, only one total detail would be in the response.

So we can't paginate, and instead we assign only the relevant children. The work done here is to remove the excessive results from the array. This is important because subsequent sideloads will scope to that array.

To make this work, we ensure the assign block is fired before processing further sideloads, which makes better mental sense in any case.

See also: https://github.com/rails/rails/issues/10621