3

In AEM when I try to run following query:

{   benefitProgramByPath(_path: "/content/dam/rahjang-cf/rahjang-benifit") {
    item {
      _metadata {
        stringMetadata {
          name,
          value,
          __typename
        }
        stringArrayMetadata {
          name,
          value,
          __typename
        }
        intMetadata {
          name,
          value
        }
        intArrayMetadata {
          name,
          value
        }
        floatMetadata {
          name,
          value
        }
        floatArrayMetadata {
          name,
          value
        }
        booleanMetadata {
          name,
          value
        }
        booleanArrayMetadata {
          name,
          value
        }
        calendarMetadata {
          name,
          value,
          __typename
        }
        calendarArrayMetadata {
          name,
          value
        }
      }
      
    }
      } }

it gives me following response

{
  "data": {
    "benefitProgramByPath": {
      "item": {
        "_metadata": {
          "stringMetadata": [
            {
              "name": "title",
              "value": "rahjang-benifit",
              "__typename": "StringMetadata"
            },
            {
              "name": "description",
              "value": "",
              "__typename": "StringMetadata"
            }
          ],
          "stringArrayMetadata": [],
          "intMetadata": [],
          "intArrayMetadata": [],
          "floatMetadata": [],
          "floatArrayMetadata": [],
          "booleanMetadata": [],
          "booleanArrayMetadata": [],
          "calendarMetadata": [],
          "calendarArrayMetadata": []
        }
      }
    }
  }
}

The name and title are getting picked up respectively from ./jcr:content/jcr:title and ./jcr:content/jcr:description. It doesn't give the created date which is default metadata of the content fragment as well as the last modified date. These reference to ./jcr:content/jcr:created and ./jcr:content/jcr:lastModified respectively.

On investigation I found GraphQL returns only the metadata for a content fragment which is stored under ./jcr:content/metadata node. But somehow it creates exception for title and description since these are not stored under ./jcr:content/metadata node and instead are stored on ./jcr:content node.

How can I make GraphQL return jcr:lastModified date as part of metadata ?

rahul
  • 61
  • 6

0 Answers0