I'm currently working on a relation-heavy website with a colleague of mine and, for that reason, eager-loading stuff looks very appealing to us. We've succeeded in eager-loading pretty much everything that we needed but there is just one kind of template that we couldn't make it work with: paginated archives
The context: We have this archive page that loads every entry of a 'projects' section and, next to each entry, we have a list of all images that the entry contains which is between 8-20 images (remember, I said it was relation-heavy ;) ). We care a lot about performance so we decided to paginate this big entry listing.
The issue: All this works very well except that when we tried to eager-load those images, we transformed our original query which was:
{% set allProjects = craft.entries(queryParams).limit(itemsPerPage) %}
to
{% set allProjects = craft.entries(queryParams).limit(itemsPerPage).find({
with: [
'gridMatrixBlock1:rowItem1',
['gridMatrixBlock1:rowItem1.gridimageFile', {
kind: 'image',
withTransforms: projectThumb
}],
...
]
}) %}
The question: Since .find() returns an array, we have no way to paginate this (pagination need an ElementCriteriaModel). Is there any workaround I don't know about?