- 🇩🇪Germany geek-merlin Freiburg, Germany
To fix #13, the for loop should be replaced with sth like:
$entities = $this->entityTypeManager->getStorage($entity_type_id)->loadByProperties([$uuid_key => $uuids]);
The proliferation of UUIDs in both GraphQL and JSON:APIs make the scenario of receiving an array of UUIDs as input. The entity repository can already be used to load a single entity by uuid (EntityRepository::loadEntityByUuid
) but using this to load groups of entities is inefficient.
An example use case would be assigning a bunch of tags to a piece of content or adding a lot of users to a group through a mutation. Here the tags or users can be provided as an array of UUIDs.
Introduce a EntityRepository::loadEntitiesByUuids
method that can load multiple entities of the same type from an array of UUIDs. Behaviour for invalid UUIDs will match the behaviour of EntityStorageInterface::loadMultiple
where the array of loaded entities may have a smaller size than the input array of UUIDs and only entities with a valid UUID will be loaded. An empty array of UUIDs will not be supported.
Since adding methods to EntityRepositoryInterface
would constitute a breaking change, this change is either limited to 10.0.0 unless a backwards compatible way can be thought of. One method may be adding a separate interface in Drupal 9, but this would complicate the update to Drupal 10 where that interface would stop to exist.
None
Drupal's EntityRepository
service now has a loadEntitiesByUuids
that can load multiple entities of the same type from an array of UUIDs.
None
Not all content is available!
It's likely this issue predates Contrib.social: some issue and comment data are missing.
To fix #13, the for loop should be replaced with sth like:
$entities = $this->entityTypeManager->getStorage($entity_type_id)->loadByProperties([$uuid_key => $uuids]);