Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

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

Avatar

Level 5

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?

1 Accepted Solution

Avatar

Correct answer by
Level 5

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

View solution in original post

1 Reply

Avatar

Correct answer by
Level 5

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