Eager load record on Edit Page

Instead of extending getEloquentQuery which affects ListRecords page, how can I add eager loading to the CreateRecord only? The same way you can do this for ListRecords using getTableQuery
6 Replies
Dennis Koch
Dennis Koch2y ago
Why do you want to eager load a single record?
gizmojo
gizmojoOP2y ago
Sorry maybe not the best example... on the EditRecord I want to add eager loading which doesn’t affect the ListRecord
Dennis Koch
Dennis Koch2y ago
Yes. But if you don't want eager loading on ListRecord, what's the sense of eager loading? There is only one $record on the edit page. I don't think there will be any difference in performance.
gizmojo
gizmojoOP2y ago
Yes so that it’s cached and not running duplicate queries. I have a relational database and deep nested form that includes lots of helper hints and lookups. Find it faster/cleaner to use eager loading to fetch this data from the relations of the record instance, instead of cluttering the page with lots of duplicate eloquent lookups.
Dennis Koch
Dennis Koch2y ago
Okay, valid point. You can probably overwrite the mount() to preload. Don't forget to call parent::mount()
gizmojo
gizmojoOP2y ago
Cheers that’s worked perfectly quick switch to load instead of with. Yeah defiantly wouldn’t’ want to forget the authorization check 🙂 See how it does I might need to run the load before the fillForm is called
Want results from more Discord servers?
Add your server