Support a special "latest" keyword to identify a revision for Entity Reference Revision fields

Created on 21 June 2019, about 6 years ago
Updated 21 August 2025, 24 days ago

Using entity_reference_revisions fields w/ JSON:API in write-mode is quite hard because you have to know the (numerical) revision identifier to pass in "meta" : { "target_revision_id": ... }.

This is (more and more) a widespread issue because entity_reference_revisions field type is the underlying field type for referencing paragraphs, which is, in turn, heavily used in complex content models.

But most of the time, you just want to reference "the latest revision".

So let's implement a Field Enhancer in JSON:API Extras to allow consumers to pass a special token instead of the numerical id and swap that on the fly.

I propose : @<entity_type>:latest

The reason we need to require the consumer to provide the target entity type is because currently we have no means of getting this info from field info in the enhancer implementation.

The body of a JSON:API request data would look like the following example :

        {
            "data": {
                "id": "2f791080-aa7e-46b9-86bc-cd5a494413c6",
                "type": "node--article",
                "relationships": {
                    "field_associated_content": {
                        "data": {
                            "type": "node--page",
                            "id": "31ed9d00-9a62-428c-8800-38880d93f982",
                            "meta": {
                                "target_revision_id": "@node:latest"
                            }
                        }
                    }
                }
            }
        }
Feature request
Status

Needs review

Version

3.0

Component

Code

Created by

🇨🇦Canada garphy Montreal, Canada

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024