What's the GraphQL query to get data based on variation in GraphQL ? | Community
Skip to main content
Level 4
September 27, 2022
Solved

What's the GraphQL query to get data based on variation in GraphQL ?

  • September 27, 2022
  • 1 reply
  • 806 views

Hi team, I am using GraphQL API in AEM and wanted to know how can I query variation based data from a content fragment?

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 lukasz-m

Hi @spidey1405,

I think you can do something like this:

{
  cityList (variation: "variation_name") {
    items {
      _path
      name
      country
      population
      categories
    }
  }
}

Under below page you will find more sample queries (including variation usage) that could be useful:

1 reply

lukasz-m
Community Advisor
lukasz-mCommunity AdvisorAccepted solution
Community Advisor
September 27, 2022

Hi @spidey1405,

I think you can do something like this:

{
  cityList (variation: "variation_name") {
    items {
      _path
      name
      country
      population
      categories
    }
  }
}

Under below page you will find more sample queries (including variation usage) that could be useful:

Level 4
September 27, 2022

@lukasz-m 

I am writing this query:

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

but this still gives me master version only.

 

Okay a slight correction, your variation must be lower cased and spaces should be replaced with _ and then it should work fine.

Here are some examples:

Variation Name: Variation 01
then in query it must be `variation:"variation_01"`