EagerLoadingFieldInterface ​
- Type
- Interface
- Namespace
- craft\base
- Implemented by
- craft\fields\Addresses, craft\fields\Assets, craft\fields\BaseRelationField, craft\fields\Categories, craft\fields\Entries, craft\fields\Matrix, craft\fields\Tags, craft\fields\Users
- Since
- 3.0.0
EagerLoadingFieldInterface defines the common interface to be implemented by field classes that support eager-loading.
Public Methods ​
| Method | Description |
|---|---|
| getEagerLoadingGqlConditions() | Returns an array that lists the scopes this custom field allows when eager-loading or null if eager-loading should not be allowed in the GraphQL context. |
| getEagerLoadingMap() | Returns an array that maps source-to-target element IDs based on this custom field. |
getEagerLoadingGqlConditions() ​
- Since
- 3.3.0
Returns an array that lists the scopes this custom field allows when eager-loading or null if eager-loading should not be allowed in the GraphQL context.
Returns ​
getEagerLoadingMap() ​
Returns an array that maps source-to-target element IDs based on this custom field.
This method aids in the eager-loading of elements when performing an element query. The returned array should contain the following keys:
map– an array defining source-target element mappingselementType(optional) – the fully qualified class name of the element type that should be eager-loaded, if each target element is of the same element typecriteria(optional) – any criteria parameters that should be applied to the element query when fetching the eager-loaded elementscreateElement(optional) - an element factory function, which will be passed the element query, the current query result data, and the first source element that the result was eager-loaded for
Each mapping listed in map should be an array with the following keys:
source– the source element IDtarget– the target element IDelementType(optional) – the target element type (only checked for if the top-level array doesn’t specify anelementTypekey)
Alternatively, the method can return an array of multiple sets of mappings, each with their own nested map, elementType, criteria, and createElement keys.
See also craft\base\ElementInterface::eagerLoadingMap()View source
Arguments ​
$sourceElements(craft\base\ElementInterface[]) – An array of the source elements
Returns ​
\craft\base\EagerLoadingMap, \craft\base\EagerLoadingMap[], null, false – The eager-loading element ID mappings, false if no mappings exist, or null if the result should be ignored.