Uploaded image for project: 'Magnolia REST Framework'
  1. Magnolia REST Framework
  2. MGNLREST-161

Delivery endpoint can return subnodes as an array

XMLWordPrintable

    • Icon: New Feature New Feature
    • Resolution: Unresolved
    • Icon: Neutral Neutral
    • None
    • None
    • None
    • None
    • Yes
    • Yes
    • 8

      Create a configuration option to allow subnodes to be returned as an array of nodes

      User story:

      As a SPA developer, I can get node content returned directly in arrays, so that I can work with content in a familiar and productive way. 

      Notes:

      Currently the delivery endpoint returns subnodes directly as properties on the parent node, and then a '@nodes' array which includes the names of all of those properties. While this can have advantages when a developer is trying to access a specific node, (because they can just get it by its name) it makes the usecase of accessing lists of subnodes (such as areas, pages, blocks) harder because it adds a level of indirection. Practically in a React or Angular app this can be awkward. So much so that developers have asked us how to iterate over the nodes.

      Acceptance criteria:

      • A  way to configure a delivery endpoint to return arrays of subnodes.
      • Ideally in a way that also still allows access to "non-list" subnodes by name.
      • Ideally in a way that nodes with two types of children can generate more than one array.

      Suggestion:

      Add the ability to define which nodetypes should be returned in arrays. Any node that is not in one of the specified types is still returned as a direct subnode.

      So if I specify:

      workspace: website
      arrays:
        - pages:
          nodeType: mgnl:page
        - areas:
          nodeType: mgnl:area

      Then the content will include a 'pages' and 'areas' arrays, which includes the subnodes contents. And any subnode NOT included in those arrays will still be included directly on the parent object, and still be listed in the @nodes array.

       

       

       

       

        Acceptance criteria

              Unassigned Unassigned
              rgange Richard Gange
              Votes:
              7 Vote for this issue
              Watchers:
              5 Start watching this issue

                Created:
                Updated: