Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Content]: Eager Loading should mention what field types and properties benefit/support it #516

Open
AugustMiller opened this issue Jun 28, 2023 · 1 comment

Comments

@AugustMiller
Copy link
Contributor

Product

Other/Multiple/Not Sure

Description

We aren't currently explicitly listing the fields and/or properties of elements that can be eager-loaded.

This may have to be "generic," but should still be front-and-center, i.e. "Only properties and custom fields that reference other elements can be eager-loaded."

Additionally, not all fields and/or related elements need to be eager-loaded. We can cover situations where you are apt to see performance improvements vs situations where you won't see any benefit.

This may include a mention of the eager-loading-in-place service method:

{% do craft.app.elements.eagerLoadElements(
  className(entry),
  [entry],
  [
     ...
  ]
) %}
@MattWilcox
Copy link
Contributor

MattWilcox commented Jun 28, 2023

May also be worth mentioning that if you do try to eager load a field that doesn't support it, you'll get blank data for the field instead of the actual data.

Ask me how I know.

{% do craft.app.elements.eagerLoadElements(
	className(product),
	[product],
	[
		'listingImage',
		'whoopsNotEagerLoadable'
	]
) %}

{% for thing in product.whoopsNotEagerLoadable %}
	...
{% endfor %}

Results in nothing, but if you remove whoopsNotEagerLoadable from the Eager Loading you get the data in that field.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants