After posting my original middlware solution above I’ve found a potentially harmful side effect.
If I alter the ctx in that way for the book endpoint and then at some point later, I call the book-shops endpoint, the altered ctx is retained between calls.
This is fine if we’re just editing the populate array but I tried to use this mechanism to alter the page.pageSize for a single endpoint.
Subsequent requests that then define a limit fail as you can’t provide both a limit & pageSize together.
I’ve posted a Github issue to get to the bottom of whether that’s expected behaviour or not.