rexlabsio / smokescreen-laravel-php

Library for integrating the Smokescreen transformation library with the Laravel framework
MIT License
4 stars 1 forks source link

Default eager loading #19

Open lachlankrautz opened 4 years ago

lachlankrautz commented 4 years ago

Problem

Smokescreen support for nested eager loading is quite good; each relation can define multiple nested eager loads that will be passed to eloquent. However if your transformer uses nested data without includes then there needs to be way to define top level eager loading.

eg

Events check their calendar for permissions do decide what fields can show in the transformer. So even though I’m not including the calendar I need to eager load it for the permissions check.

Solution

Minor update 2.0.0 -> 2.1.0:
ababkov commented 4 years ago

I’ve 100% needed this - will save us from putting it on the model which has felt pretty dirty (in some instances... though perfectly reasonable in others) especially given that the eager loads required may depend on the endpoint / direction that's being hit. I'm curious how this works with nested transformers (if at all).