markhuot / craftql

A drop-in GraphQL server for Craft CMS
Other
319 stars 53 forks source link

Eager loading? #159

Open timkelty opened 6 years ago

timkelty commented 6 years ago

Not sure how feasible this would be, but ideally queries with nested element queries would employ eager-loading to improve performance: https://docs.craftcms.com/v3/dev/eager-loading-elements.html#app

Other n+1 discussion: https://github.com/markhuot/craftql/issues/150

markhuot commented 6 years ago

I'm doing this a little already. Any time you pull a list of entries, if you ask for the author field I tack on ->with('author'),

https://github.com/markhuot/craftql/blob/978fc2d7aa8e3761e1289dc149ac643afd6f6cb6/src/Request.php#L139-L145

There's definitely some more places I can be doing this but I haven't gotten around to it yet. I'll look and see what sort of eager loading I can do on the entries/assets fields, next.