Problem/Motivation

When querying languages with the 'direction' option results with an error message.

{
  "errors": [
    {
      "message": "Internal server error",
      "extensions": {
        "category": "internal"
      },
      "locations": [
        {
          "line": 8,
          "column": 9
        }
      ],
      "path": [
        "entityQuery",
        "items",
        0,
        "direction"
      ]
    },

Steps to reproduce

1. Enable entity type `configurable_language (Language)`
2. Go to explorer and query languages with direction.

query MyQuery {
  entityQuery(entityType: CONFIGURABLE_LANGUAGE) {
    total
    items {
      ... on ConfigurableLanguage {
        id
        name
        direction
      }
    }
  }
}

Proposed resolution

Per https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Language%... getDirection() returns a string.

Change direction: Int! to direction: String! in /graphql/core/LanguageInterface.graphqls.

This will give expected result:

{
  "data": {
    "entityQuery": {
      "total": 31,
      "items": [
        {
          "id": "ar",
          "name": "Arabic",
          "direction": "ltr"
        },
        {
          "id": "cs",
          "name": "Czech",
          "direction": "ltr"
        },
        {
          "id": "da",
          "name": "Danish",
          "direction": "ltr"
        },
Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

justclint created an issue. See original summary.

webflo made their first commit to this issue’s fork.

webflo’s picture

Version: 1.0.20 » 1.0.x-dev
Status: Active » Needs review

This could also be implemented as ENUM, since it did not work anyway, it is not a BC break?

czigor’s picture

Status: Needs review » Needs work

This change still creates a schema validation error: Interface field LanguageInterface.direction expects type String! but ConfigurableLanguage.direction is type String.

  • czigor committed caf8d42b on 1.0.x authored by webflo
    Issue #3488674: Fix type of LanguageInterface.direction
    
czigor’s picture

Status: Needs work » Fixed

If the "Language Extension" (language_schema) extension is enabled the direction has a LanguageDirection! type.

Otherwise it's just a String.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.