rexlabsio / smokescreen-laravel-php

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

Recursive Eager Loading + Limit and Sorting Support #1

Open ababkov opened 6 years ago

ababkov commented 6 years ago

Based on what I can see at the moment (i could be wrong - i can't get the demo to fully work for me so i can't be sure), eager loading will only work for the current resource + its immediate includes. Going any more than one level down with includes will still lead to a diluted version of the original N+1 problem.

This issue isn't that urgent - it affects deeply nested includes only and perf issues would likely only be seen on reasonably sized data sets.

This is mostly a brain dump for myself (happy to have thoughts though) to allow for some time to think on this and possible approaches.

For example, for the following include string assuming it's in the context of a top level post model: id,user{email,id},comments{user{email,id,comments{post{id}}

This breaks out into something like:

Dealing with eager loading recursively

Dealing with limits, ordering and eager loading

Limits on sub relationships aren't supported in eloquent, something like this might work

ababkov commented 6 years ago

Might be worth looking at something like this for async loading (may be easier to reconcile in certain places)... not sure how to reconcile this all back to sync transformers. Something to investigate longer term probably.