Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[4.x]: localized gql property returns empty array when using a preview token #13924

Closed
weotch opened this issue Nov 9, 2023 · 2 comments
Closed

Comments

@weotch
Copy link
Contributor

weotch commented Nov 9, 2023

What happened?

Description

The localized gql property is empty when the request is made with a Craft preview token.

Steps to reproduce

Make a query like this to an entry that has been added to multiple sites:

query {
  entries(site: "fr_fr", uri: "fr-fr/articles/the-power-of-yes") {
    id
    title
    localized(site:"en") {
      id
      title
    }
  }
}

Try it with and without a Craft preview token.

Expected behavior

The localized property to return the same value, regardless of whether previewing

Actual behavior

Without token query param:

{
  "data": {
    "entries": [
      {
        "id": "6806",
        "title": "Le pouvoir du « oui »",
        "localized": [
          {
            "id": "6806",
            "title": "The Power of Yes"
          }
        ]
      }
    ]
  }
}

With query param:

{
  "data": {
    "entries": [
      {
        "id": "2249945",
        "title": "Le pouvoir du « oui »preview",
        "localized": []
      }
    ]
  }
}

Example of the request I'm making with a token:

curl --request POST \
  --url 'https://domain.com/api?token=JBdBAgdNw6B1Cwu_enp-1goV_RzU0W5j' \
  --header 'Content-Type: application/json' \
  --data '{"query":"query getArticles {\n  entries(\n    site: \"fr_fr\"\n\t\turi: \"fr-fr/articles/the-power-of-yes\"\n\t) {\n    id\n    title\n    localized(site:\"en\") {\n      id\n      title\n    }\n  }\n}\n","operationName":"getArticles"}'

Craft CMS version

4.5.6.1

PHP version

8.0.30

Operating system and version

Darwin 23.0.0

Database type and version

MySQL 8.1.0

Image driver and version

GD 8.0.30

Installed plugins and versions

  • Bulk Edit 4.0.1
  • Bulk Propagator dev-main
  • Colorit 4.0.0
  • Control Panel CSS 2.6.0
  • Control Panel JS 2.6.0
  • Dashboard Begone 2.0.0
  • DigitalOcean Spaces Filesystem 2.0.0
  • Mixpanel dev-main
  • Neo 3.9.4
  • Redactor 3.0.4
  • Scout 3.2.1
  • Smartling Connector dev-main
  • Super Table 3.0.9
  • Translations 3.0.3
  • Webhooks 3.0.5
@brandonkelly
Copy link
Member

Thanks for reporting! Just fixed that for the next release.

If you want to get the fix early, change your craftcms/cms requirement in composer.json to dev-develop as 4.5.10, and run composer update.

@brandonkelly
Copy link
Member

Craft 4.5.11 is out with that fix. Thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants