Replies: 1 comment 1 reply
-
@phh If you still had the macro handy, could you post it? |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi there,
Today I was tracking down lazy-loaded relations in our code base. One thing is fixing the error when a property is lazy loaded, another thing is actually determining if the loaded relationship is necessary when relying on includes.
So, an example:
I have a
Book
model that has aBookTransformer
. Easy enough. However, thisBook
also have a relation to anAuthor
which is made up by multiple relationships like:To avoid having to load this author everytime, I'm letting the consumer of the API decide when to include this with the
?include=author
GET parameter.However, that introduces a new problem: When to eager load the relationships in the controller?
I could check the get parameter for includes but:
Short version: I made a macro to determine if the include is included. Is this something you have reached for before that you would like me to PR?
Currently the macro I made will make the following available:
Beta Was this translation helpful? Give feedback.
All reactions