Problem/Motivation
Revision support for individual entities will be provided in #2992833: Add a version negotiation to revisionable resource types. For entities that support revisioning, add revision links in serialized json api output for an individual entity for those revisions supported by the initial feature, rel:working-copy, rel:latest-version, and id:.
Proposed Solution
Add links to the links data structure for individual entities. These version links will only be included if the entity being returned supports revisions. The links to be included with use the revision id negotiation features in proposed in #2992833: Add a version negotiation to revisionable resource types, specifically the rel plugin negotiation:
GET /jsonapi/node/page/{uuid}?current_version=rel:working-copy
GET /jsonapi/node/page/{uuid}?current_version=rel:latest-version
Comments
Comment #2
wim leersComment #3
e0ipsoInitial patch to add revision links. This patch depends on #2992833: Add a version negotiation to revisionable resource types. Added combined patch here.
Comment #4
e0ipsoBlocking on #2992833: Add a version negotiation to revisionable resource types.
Comment #6
e0ipsoStand-alone patch here.
Comment #7
e0ipsoNow that the plugin issue is back to green, let's get this re-tested.
Comment #9
e0ipsoThis patch will add links to the collections as well.
Comment #10
e0ipsoThere was a missing
usestatement.Comment #11
wim leersI'd also like to see
working-copy-of, which should appear for non-default revision normalizations.Comment #12
e0ipsoThis adapts the patch to the latest state of #2992833: Add a version negotiation to revisionable resource types.
Comment #14
e0ipsoComment #15
wim leersNow that #2992833: Add a version negotiation to revisionable resource types is RTBC, let's move this forward again! 💪
Comment #16
wim leersComment #17
e0ipsoComment #18
wim leers#2992833: Add a version negotiation to revisionable resource types landed! Let's do this now :)
Comment #19
gabesulliceI'd sort of like this to wait for #2995960: Add a Link and LinkCollection class to support RFC8288 web linking.. Any opposed?
Comment #20
wim leersNot opposed, but slightly concerned since that could take a while. But with 2.0 out, hopefully we can make significant progress there :)
Comment #21
wim leersComment #22
wim leersComment #23
wim leers#3022584: Consolidate and simplify NormalizerValue objects: introduce CacheableNormalization landed, which unblocked #2995960: Add a Link and LinkCollection class to support RFC8288 web linking..
Comment #24
wim leers#2995960: Add a Link and LinkCollection class to support RFC8288 web linking. landed!
Comment #25
gabesullice#2995960: Add a Link and LinkCollection class to support RFC8288 web linking. landed and added the
LinkCollectionclass which I wanted to be used to add these links. However, it did not actually make use of LinkCollections on the resource object level. #3015438: Wrap entity objects in a ResourceObject which carries a ResourceType will accomplish that.Comment #26
wim leersComment #27
wim leersCurrently scrutinizing #3015438: Wrap entity objects in a ResourceObject which carries a ResourceType prior to commit. I wanted to be absolutely certain that this issue is indeed not only possible thanks to that other issue, but also significantly simpler in terms of code. I'm happy to report that this turns out to be true! In #12, we had to modify both the entity normalization and the top-level document normalization — even though both were for entities. Thanks to #3015438, we'll only have to make additions in one place. It also helps validate #2994193: [META] The Last Link: A Hypermedia Story :)
Comment #28
wim leers#3015438: Wrap entity objects in a ResourceObject which carries a ResourceType landed.
Comment #30
gabesulliceSUPER pleased to see how simple this is now :D
Just a couple thoughts:
I think the
selflinks should be?resourceVersion=rel:{vid}if the resource type is versionable.These should only appear if this particular version is not the latest version or working copy.
Comment #31
wim leers#30: be my guest to make that happen :) I'm glad the tests are catching the changes in JSON:API responses!
Comment #32
wim leerslatest-version? I think because it allows the client to track server-side changes more easily, but I'd like us to document this explicitly.Comment #34
gabesullice#32:
1. Yes, and to easily disambiguate resource objects in #3009588: Provide a collection resource where a version history can be obtained (`version-history`, `predecessor-version` and `successor-version` link relations).
2. 😗👌
I'll push this over the finish line tomorrow.
Comment #35
gabesulliceOkay, this should apply the appropriate expectations for resource object links (
self,working-copyandlatest-version).In doing this I realized that we probably also need to update the
selfandrelatedlinks under relationship objects. A relationshipselflink is essentially a URI for that relationship object. If a relationship differs between revisions, we don't want the relationship object on an individual response to be different from the result if the link is followed.Let's add tests for those.
I don't want this next bit to block this issue because this issue has already sat for too long... but I do want to plant this seed now:
I didn't expect these links to be added within the
ResourceObjectclass. I was hoping we would use this issue to pilot a more public API for LinkCollections (but keep it internal until we were satisfied with it).I envisioned either a tagged service or plugin called a "link provider". It would be passed a
LinkCollectionobject. In this issue, we would have implemented that service/plugin within theRevisionsnamespace (meaning all revision stuff was completely contained in that space). E.g.:Comment #38
gabesulliceComment #40
gabesulliceWhile I hate to make another prerequisite here, I think #3033473: Clean-up: Remove LinkManager is super close and will make this change a go a little smoother. It will also avoid having to reroll the change completely and will be more conceptually similar to what I showed in #35.
After we get this green, we can mark it Postponed, in the mean time, I'll keep them in sync as necessary.
Comment #42
gabesulliceWhoops, missed one variable rename.
Comment #44
gabesullice#3033473: Clean-up: Remove LinkManager landed!
Comment #45
gabesulliceThis should be green 🤞
Comment #46
wim leersLooks 😍
Comment #48
gabesullice