Variation in AEM: Returns the master data if variation not found, but I only want the content fragments with variations | Community
Skip to main content
Level 4
September 27, 2022
Solved

Variation in AEM: Returns the master data if variation not found, but I only want the content fragments with variations

  • September 27, 2022
  • 1 reply
  • 615 views

So I have a query like this:

query { articlesList(variation:"spanish") { items { _path, title, } } }

 

This works fine but if I don't have a Spanish variation for a specific `Article` content fragment then it returns the master variation. However ideally I want it to return all the articles which have those variations and if they don't then return nothing. How do I go about solving this?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by spidey1405

Got it sorted by performing variation as filter, instead of variation

query {
  articlesList(variation:"spanish",filter:{
    _variation: {
      _expressions: [
        {
          value: "spanish",
          _operator: EQUALS,
          _ignoreCase: true
        }
      ]
    }
  }) {
    items {
      _path,
      title,
      
    }
  }
}

1 reply

spidey1405AuthorAccepted solution
Level 4
September 27, 2022

Got it sorted by performing variation as filter, instead of variation

query {
  articlesList(variation:"spanish",filter:{
    _variation: {
      _expressions: [
        {
          value: "spanish",
          _operator: EQUALS,
          _ignoreCase: true
        }
      ]
    }
  }) {
    items {
      _path,
      title,
      
    }
  }
}