Versions Compared

Key

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

...

I think it would make more sense to configure any references to expand directly on the component itself. The component includes the rendering, so it would make sense that it could define which properties are references and should be expanded. 

Then the endpoint could "walk the tree" of components and for each component, resolve any references based on the special new configuration on that component. (So it would be working somewhat like the freemarker renderer does.)


How could this be configured?

Lets use example from travel demo of the TourCarousel. Here is the dialog definition.

A tour has an image  and tourTypes .

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

In component template definition?

/components/tourCarousel.yaml

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

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

# Handle subproperties:

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




As a GraphQL fragment?

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


/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
            }
        }
    }
}