1

I'm using a GraphQL query that at its most basic looks like this:

{
  item(path: "/sitecore/content/Home", language: "en") {
    name
    languages {
      name
      version
      language {
        name
      }
    }
  }
}

I have two languages configured under /sitecore/system/Languages, en and es, however, the item only has an en version and no es version. Language fallback is not enabled.

When executing this query, instead of only getting the en version, I get both languages back, like so:

{
  "data": {
    "item": {
      "name": "Home",
      "languages": [
        {
          "name": "Home",
          "version": 1,
          "language": {
            "name": "en"
          }
        },
        {
          "name": "Home",
          "version": 1,
          "language": {
            "name": "es"
          }
        }
      ]
    }
  }
}

Is there a good way to either:

  • correctly return only the languages that have actual versions?
  • or, return some kind of flag along with the version item so it can be filtered out at consumption?
2
  • Hi @George Chang, I have tried the same query in my EDGE, but im getting only EN Version alone, not the other language version which i have not created. But if I created and published the other language version to the EDGE then i can able to get both language item details. But once i removed that other language item and published to EDGE , now getting only getting EN item. I guess es version item might be already in EDGE, mine also language fallback not enabled, for now i couldn't reproduce this issue. i will try to find and provide more info.
    – Nelson
    Commented Feb 13 at 7:31
  • Query only returns the language you have configured on item. Commented Mar 8 at 14:14

1 Answer 1

0

Get List of all language versions for particular item

query GQLQuerySamples( $contextItem: String!) {
    GQLType: item(path: $contextItem) {
      versions(allLanguages: true)
        {
         name,
         language {
          name
         }
        }
    }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.