Expand my Community achievements bar.

Nested Inline RTE references in AEM GraphQL

Avatar

Level 1

Im working with AEM content fragments and trying to fetch the data using GraphQL.

Below is my query -

{
  productByPath(_path: "/content/dam/my/product", variation:"master") {
    item {
      productDescription {
        html
      }
    }
    _references {
      ... on DisclaimerModel {
        productDisclaimer {
          html
        }
      }
      ... on DiscountModel {
        _path
        discountPercent
      }
      ... on AbnModel {
        _path
        abn
      }
    }
  }
}

 

I am trying to fetch all content fragment references from the productDescription RTE of the product content fragment. The query works fine and I am able to fetch the references.

Now the productDisclaimer is also an RTE and contains references to other content fragments that I want to fetch. If there a way to nest _references ? 

 

1 Reply

Avatar

Community Advisor

HI @ArchitAr2 ,

You can try to take reference from below query,illustrates filtering for any person of name “Smith”, returning information from across two nested fragments - company and employee.

 

query {
  companyList(filter: {
    employees: {
      _match: {
        name: {
          _expressions: [
            {
              value: "Smith"
            }
          ]
        }
      }
    }
  }) {
    items {
      name
      ceo {
        name
        firstName
      }
      employees {
        name
        firstName
      }
    }
  }
}

 

For more details on it, look into below link:
https://experienceleague.adobe.com/en/docs/experience-manager-cloud-service/content/headless/graphql...

 

 

-Tarun