GraphQL not using the fallback language

I have…

I’m submitting a…

  • [ ] Regression (a behavior that stopped working in a new release)
  • [X] Bug report
  • [ ] Performance issue
  • [ ] Documentation issue or request

Current behavior

I’ve setup multiple languages. English (en) is my master language. Dutch (nl) is an optional language with English (en) as it’s fallback language.

I have a Page schema with a pageTitle that is marked as localizable and required. If I provide an English value and no Dutch value, my GraphQL query gives me back null values when i send the “X-Languages: nl” header.

Expected behavior

I would expect GraphQL to return the fallback language for any property that isn’t localized. In this case, it should return the English title, instead of null.

Minimal reproduction of the problem

Language Configuration:

GraphQL Query:

{
  queryPagesContents {
    id,
    data {
      pageTitle {
        nl,
        en
      }
    }
    flatData {
      pageTitle
    }
  }
}

Result (X-Languages: nl,en):

{
  "data": {
    "queryPagesContents": [
      {
        "id": "06b3a7f3-cb0f-4964-8daf-029c3df667a3",
        "data": {
          "pageTitle": {
            "nl": "Dutch Homepage",
            "en": "English Homepage"
          }
        },
        "flatData": {
          "pageTitle": "English Homepage"
        }
      },
      {
        "id": "edf46ef4-25e8-4369-9909-e7dae6f2c5ca",
        "data": {
          "pageTitle": {
            "nl": null,
            "en": "Multilang Test"
          }
        },
        "flatData": {
          "pageTitle": "Multilang Test"
        }
      },
      ....

Result (X-Languages: nl):

{
  "data": {
    "queryPagesContents": [
      {
        "id": "06b3a7f3-cb0f-4964-8daf-029c3df667a3",
        "data": {
          "pageTitle": {
            "nl": "Dutch Homepage",
            "en": null
          }
        },
        "flatData": {
          "pageTitle": "Dutch Homepage"
        }
      },
      {
        "id": "edf46ef4-25e8-4369-9909-e7dae6f2c5ca",
        "data": {
          "pageTitle": {
            "nl": null,
            "en": null
          }
        },
        "flatData": {
          "pageTitle": null
        }
      },
      ....

Environment

App Name:

  • [X] Self hosted with docker
  • [ ] Self hosted with IIS
  • [ ] Self hosted with other version
  • [ ] Cloud version

Version: 7.5.0.0

Browser:

  • [X] Chrome (desktop)
  • [ ] Chrome (Android)
  • [ ] Chrome (iOS)
  • [ ] Firefox
  • [ ] Safari (desktop)
  • [ ] Safari (iOS)
  • [ ] IE
  • [ ] Edge

Others:
N/A

Is the value null or undefined? Can you click the small “x” button or not?

The JSON view shows the value as null, and I cannot click the “x” button:

{
    "id": "edf46ef4-25e8-4369-9909-e7dae6f2c5ca",
    "created": {
        "value": "2023-06-08T17:56:31.000Z"
    },
    "createdBy": "subject:6452761c2c7a9b93572f41f2",
    "lastModified": {
        "value": "2023-06-08T17:56:31.000Z"
    },
    "lastModifiedBy": "subject:6452761c2c7a9b93572f41f2",
    "version": {
        "value": "1"
    },
    "status": "Published",
    "statusColor": "#4bb958",
    "scheduleJob": null,
    "isDeleted": false,
    "data": {
        "pageName": {
            "en": "Multilang Test",
            "en-AW": null,
            "en-BM": null,
            "en-JM": null,
            "es": null,
            "fr": null,
            "nl": null,
            "nl-AW": null
        },
        "pageTitle": {
            "en": "Multilang Test",
            "en-AW": null,
            "en-BM": null,
            "en-JM": null,
            "es": null,
            "fr": null,
            "nl": null,
            "nl-AW": null
        },
        ...

BTW I appreciate the quick reply

Squidex differentiates between null and undefined and null is a valid value, that does not trigger the fallback handling. Could have a look to the database, just to be sure?

But the point that you cannot click “x” is an indicator that the field has no value for the language.

EDIT: I can have a closer look tomorrow.

As far as I can tell from the database, there just isnt a value for that field for other languages. I even created a new test schema just now to test, two localized fields, one regular field, created a single item without touching any of the other languages. Same behavior. I even went into the JSON data view and deleted the other languages from the field. Same behavior as well

Data view:

{
    "name": {
        "en": "English Name"
    },
    "label": {
        "en": "English Label"
    },
    "slug": {
        "iv": "test-item"
    }
}

Query results with X-Languages: nl

{
  "data": {
    "queryTestContents": [
      {
        "data": {
          "name": {
            "en": null,
            "nl": null
          }
        },
        "flatData": {
          "name": null,
          "label": null,
          "slug": "test-item"
        }
      }
    ]
  }
}

chrome_2023-06-08_15-48-46

No worries, I appreciate the quick replies, I’ll check back tomorrow to see if you’ve had a chance to look. Have a good day!

Btw: Which token do you use? If the token is from the UI, the fallback handling is not applied.

Ah that was the issue. I wasn’t aware that the UI had a special token. Thank you very much, sorry for the bother!

1 Like

Perhaps we can add an option to the GraphQL playground to select a client.

I think that would be a very useful feature. Maybe a language selector too, just a little easier then going in to add headers (and more discoverable, as the headers require the user to read through the documentation instead of discovering the feature via the UI)

The languages header is not that relevant for GraphQL I would say.