Invalid translation language

Created on 15 January 2024, 10 months ago
Updated 17 January 2024, 10 months ago

Problem/Motivation

Facing an error Invalid translation language (es) specified. in Drupal\Core\Entity\ContentEntityBase->getTranslation() (line 910 of /app/docroot/core/lib/Drupal/Core/Entity/ContentEntityBase.php) when accessing a translatable node in a language for which the translation does not exist.

Steps to reproduce

  • Create a translatable node in language EN
  • Make sure the node is yet to be translated in other language, let's say ES
  • When trying to access this node with the provided code, I get an error
    query MyQuery {
      nodeArticle(langcode: "es", id: 60) {
        title
      }
    }
🐛 Bug report
Status

Closed: won't fix

Version

2.1

Component

Code

Created by

🇮🇳India rajghai

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @rajghai
  • 🇫🇮Finland vermario

    Hi!

    I had the same issue, and this is a problem of the graphql module, not the grapql_compose one.

    Development for the grapqhl module is happening on github, so I made a pull request there: https://github.com/drupal-graphql/graphql/pull/1388

    You can add those changes as a patch in your composer.json like this:

                "drupal/graphql" : {
                    "drupal-graphql#1323: Add check for translation (from Github)": "https://patch-diff.githubusercontent.com/raw/drupal-graphql/graphql/pull/1388.patch"
                },
    

    For me, this fixes the problem.

  • Status changed to Closed: won't fix 10 months ago
  • 🇦🇺Australia almunnings Melbourne, 🇦🇺

    Yeah this is an upstream issue, thanks for looking into it!

    The entity_load_by_uuid_or_id producer in graphql_compose passes off to entity_load_by_uuid and entity_load data producers, which come from the upstream GraphQL project.

    Looks like they're not checking `$entity->hasTranslation($language)`.

    Closing with:

Production build 0.71.5 2024