Originally published at hafiz.dev
On Laravel 13.38.0, a request for 20 posts with ?include=author,comments ran 41 queries through the framework's own JSON:API resources. The fix is merged into the 13.x branch. It just isn't in a release yet.
I found that while building the same small API three ways: with Laravel's built-in JsonApiResource , with timacdonald/json-api , and with laravel-json-api/laravel . Same three models (users, posts, comments), same 20 posts and 100 comments, on a clean Laravel 13.38.0 project with SQLite. Each request went through a small middleware that counts queries. All output below is real.
Two of the three look almost the same from the outside. The third is a different kind of tool. One question tells you which you need. (If you're still deciding how the API itself should behave, my production API practices post is the place to start.)
Check your version first
If you already use the built-in resources, three things depend on your Laravel version.
GHSA-5wcm-3v2w-8362.…