Load relationships on demand
See original GitHub issueCurrently, all relational data is fetched eagerly.
This could potentially be a problem with related data that has vast amount of records. It is probably not always desirable to fetch all
relational data of the parent model.
it would be great if we it were possible to somehow define what related data you want to fetch for that particular request.
Issue Analytics
- State:
- Created 5 years ago
- Comments:7
Top Results From Across the Web
Laravel Accessor on demand on relationship - Stack Overflow
I've found out how to do this: After getting the entire collection we need to call setAppends() in each model, which contains appends, ......
Read more >Eloquent: Relationships - The PHP Framework For Web Artisans
Dynamic properties are "lazy loading", meaning they will only load their relationship data when you actually access them. Because of this, developers often...
Read more >Laravel API Resource: Loading relationship the right way.
We use the with() or loadMissing() function to eager load the relationships. Remember, with() can only be called from Eloquent Query, so it...
Read more >Loading Related Data - EF Core - Microsoft Learn
Lazy loading means that the related data is transparently loaded from the database when the navigation property is accessed.
Read more >Laravel Accessor on demand on relationship - Laracasts
Problem: I have accessor in Size.php model which is called in relationship with Item.php Model, in API i need the accessor to work,...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I could imagine, that the
fetch()
method accepts ainclude
param with a list of relationships to eager load for that request. Could be useful.Moved to https://github.com/vuex-orm/plugin-graphql/issues/95