Problem/Motivation
I'm trying to use Transform API with Paragraphs, but this seems to happen with any entity reference (revisions) field. Essentially any reference fields with cardinality > 1 are buggy.
On a node, I have an 'Elements' field that references Paragraphs. The referenced Paragraph type has a text field, which is set visible in Transform Mode setting for the Paragraph.
When set as a single value field in field settings, JSON gets populated correctly with the text field value as expected, no issues.
But when the cardinality is set to unlimited, I run into issues.
1. When I empty the cache and load the JSON page, entity reference field values do not include the text field, but are otherwise ok.
2. When I save the node and again open the JSON page, every element instance on all nodes for the same field get populated with the same globally last added item (id is the same for all, and the text field is included).
Emptying the cache again restores the state where the Paragraph instances exist in JSON with their proper ids, but the text field is missing.
3. When I leave any entity reference (revisions) field empty, save the node, I get the following error instead of the JSON:
The website encountered an unexpected error. Try again later.<br><br><em class="placeholder">TypeError</em>: Drupal\transform_api\Transform\EntityTransform::getEntity(): Return value must be of type Drupal\Core\Entity\EntityInterface, false returned in <em class="placeholder">Drupal\transform_api\Transform\EntityTransform->getEntity()</em> (line <em class="placeholder">115</em> of <em class="placeholder">modules/contrib/transform_api/src/Transform/EntityTransform.php</em>). <pre class="backtrace">Drupal\transform_api\Transform\EntityTransform->getTransformBuilder() (Line: 220)
Drupal\transform_api\Transform\EntityTransform->transform() (Line: 153)
Drupal\transform_api\Plugin\Transform\Field\EntityTransform->transformElements() (Line: 108)
Drupal\transform_api\FieldTransformBase->transform() (Line: 290)
Drupal\transform_api\Entity\EntityTransformDisplay->buildMultiple() (Line: 388)
Drupal\transform_api\Entity\EntityTransformBuilder->buildComponents() (Line: 324)
Drupal\transform_api\Entity\EntityTransformBuilder->buildMultiple() (Line: 276)
Drupal\transform_api\Entity\EntityTransformBuilder->build()
My nodes are translatable, but otherwise the setup is very basic. Transform Modes on node type and Paragraphs are configured to show the fields.