Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Regarding:

Jira
serverMagnolia - Issue tracker
serverId500b06a6-e204-3125-b989-2d75b973d05f
keyMGNLREST-682


The reference resolving is a useful and popular feature, but the way it is configured causes problems for developers.

...

Code Block
form:
  properties:
    - name: tours
      $type: jcrMultiValueField
      field:
        $type: linkField
        editable: false
        datasource:
          $type: jcrDatasource
          workspace: tours

In component template definition?

Put the same reference resolver configuration in the component template definition?

Cons:

  • This might still have name conflicts, but they would be scoped much smaller - just to referenced items.

/components/tourCarousel.yaml

Code Block
title: Tour Carousel
dialog: travel:components/tourCarousel

references:
  tours:
    propertyName: tours
    referenceResolver:
      $type: JcrReferenceResolver
      targetWorkspace: tours

# Handle subproperties of tours:

   tourTypes:
    propertyName: tourTypes
    referenceResolver:
      $type: JcrReferenceResolver
      targetWorkspace: categories
 
   image:
    propertyName: image
    referenceResolver:
      $type: AssetReferenceResolver
      includeAssetMetadata: false



As

...

an optional GraphQL fragment?

GraphQL was designed to handle this kind of querying/referencing.

What if you could provide an optional GraphQL fragment next to the template definition file. If it was present, then the component would only output this content.

/components/tourCarousel.graphql(The dialog is very simple, it is basically a multiselect for "tours".)

Code Block
{
    tours: Tours{ # Need a hint to know its type
        name
        duration
        image: Asset{
            link
            renditions(renditionNames: "1600") {
                renditionName
                link
            }
        }
        tourTypes: Category{ # Need a hint to know its type
            displayName
            icon{
                link
            }
        }
    }
}


As an optional JSON fragment?

Very similar to graphql fragment above.

If developer supplies a JSON file - it overrides the default response. Maybe use actual javascript??


/components/tourCarousel.json (JUST A SKETCH!)

Code Block
{
    "tours": [
        {
            "name": `${name}`,
            "duration": `${duration}`,
            "image": {
                "link": `${image.link}`,
                "rendition": `${image.rendition["1600"]}`,
            },
            "tourTypes": [
                {
                    "displayName": `${displayName}`,
                    "icon": `${icon.link}`
                }
            ]
        }
    ]
}