EagerLoadingFieldInterface ​
- Type
- Interface
- Namespace
- craft\base
- Implemented by
- 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:
elementType
– the fully qualified class name of the element type that should be eager-loadedmap
– an array of element ID mappings, where each element is a sub-array withsource
andtarget
keys.criteria
(optional) – Any criteria parameters that should be applied to the element query when fetching the eager-loaded elements.
Arguments ​
$sourceElements
(craft\base\ElementInterface[]) – An array of the source elements
Returns ​
array, null, false – The eager-loading element ID mappings, false if no mappings exist, or null if the result should be ignored.