[MGNLREST-625] Combine template-annotations with Delivery API responses Created: 02/Feb/23  Updated: 22/May/23

Status: Accepted
Project: Magnolia REST Framework
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Neutral
Reporter: Bartosz Staryga Assignee: Unassigned
Resolution: Unresolved Votes: 1
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Template:
Acceptance criteria:
Empty
Task DoD:
[ ]* Doc/release notes changes? Comment present?
[ ]* Downstream builds green?
[ ]* Solution information and context easily available?
[ ]* Tests
[ ]* FixVersion filled and not yet released
[ ]  Architecture Decision Record (ADR)
Date of First Response:
Epic Link: SPA Editor Backlog
Team: DeveloperX

 Description   

Now for Visual SPA to work, we need to fetch extra data from `template-annotations` endpoint. It is manageable but does add extra complexity to the code.

get page content

if in magnolia
  fetch template-annotations

pass data to editable page

What if we return template annotations data in the response from Delivery API?

{
  "@name": "home",
  "@path": "/home",
  "templateAnnotation": ""cms:page ...",
  ...
  "main": {
    "@path": "/home/main",
    "templateAnnotation": ""cms:area ...",
    ...
    "0": {
      "@path": "/home/main/0",
      "templateAnnotation": ""cms:component ...",
      ...
    }
  }
}

We could simplify the code to:

get page content

pass data to editable page

How would Delivery API know to fetch those extra data? Query params that Magnolia already adds to iframe src.
We already do:

get page content // add all query param from page request

pass data to editable page

This is just a basic case, so it might seem simple, but it gets more tricky when we bring in the p13n and multiple workspaces (sales demo).

Currently, we must:

  • define new template annotations endpoints for multiple workspaces
  • ensure they use the new implementation class
  • JS needs to guess if it opens in the context of Pages App or Campain App or any other app using different workspaces and chose a correct template annotations url. It changes 2 lines of code into 50

 



 Comments   
Comment by Christopher Zimmermann [ 06/Feb/23 ]

This looks like it would make project developers lives significantly easier.It would simplify usage of the libraries.

Would make training and onboarding easier and would likely simplify documentation.

An alternative to embedding the annotations directly in the content could just be to append the annotations at the end of the content response. This would be closer to the current implementation but would bring most of the benefits.

Generated at Mon Feb 12 07:01:39 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.