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

post() and postBy() queries return null in non-default language after WPGraphQL v1.14.0 #43

Open
matthewtompkins opened this issue Apr 13, 2023 · 1 comment

Comments

@matthewtompkins
Copy link

Hello,

After upgrading to WPGraphQL v1.14.0, all single post queries in the non-default language (English) now return null.

Example:

{
  post(
    id: "les-bases-de-la-guitare-la-guitare-basse"
    idType: SLUG
  ) {
    id
  }
}

Returns:

{"data": {
    "post": null
  },}

posts() queries using { where: { wpmlLanguage: $LANG } } still behaves as expected - returning posts in only the specified language:

{
  posts(first: 10, where: {wpmlLanguage: "fr"}) {
    edges {
      node {
        id
      }
    }
  }
}

Returns:

{
  "data": {
    "posts": {
      "edges": [
        {
          "node": {
            "id": "cG9zdDoxMTg0Nzk="
          }
        },
        {
          "node": {
            "id": "cG9zdDoxMTg1NDE="
          }
        },...

Any idea what might be happening here?

Best,

Matt

@Ririshi
Copy link

Ririshi commented Apr 26, 2023

As a "quick fix" workaround, you could replace your single post queries with the posts query, limiting the output to one, like I mentioned in #13 (comment). It also works if you omit wpmlLanguage, but it might return the wrong language if you have posts with the same slug in different languages.

posts(where: {name: $slug, wpmlLanguage: $languageCode}, first: 1) {
  nodes {
    id
  }
}

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

No branches or pull requests

2 participants