Skip to content

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.

View source

Public Methods ​

MethodDescription
getEagerLoadingGqlConditions()Returns an array that lists the scopes this custom field allows when eager-loading or false 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 false if eager-loading should not be allowed in the GraphQL context.

View source

Returns ​

array, false

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-loaded
  • map – an array of element ID mappings, where each element is a sub-array with source and target keys.
  • criteria (optional) – Any criteria parameters that should be applied to the element query when fetching the eager-loaded elements.

View source

Arguments ​

Returns ​

array, false, null – The eager-loading element ID mappings, false if no mappings exist, or null if the result should be ignored.