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

Languages menu missing after Wordpress 6.1.1 update #38

Open
achi-tricentis opened this issue Dec 16, 2022 · 3 comments
Open

Languages menu missing after Wordpress 6.1.1 update #38

achi-tricentis opened this issue Dec 16, 2022 · 3 comments

Comments

@achi-tricentis
Copy link

After we updated to Wordpress 6.1.1, we no longer see the menu in other languages. GraphQL IDE does not retrieve the data either. GraphQL Version 1.13.7 and WPGraphQL WPML Version 1.1.0

@achi-tricentis
Copy link
Author

achi-tricentis commented Jan 9, 2023

Screenshot 2023-01-13 at 12 12 17 PM

Screenshot 2023-01-13 at 12 12 03 PM

@SmartyP
Copy link

SmartyP commented Jan 25, 2023

Confirming and following up with further details. Basically before WP 6.1.1 I could run a query like this:

query allMenus {
  menus {
    nodes {
      language
      locations
    }
  }
}

.. and I would get all of my menus (English, French, German). That response would look something like this:

{
  "data": {
    "menus": {
      "nodes": [
        {
          "language": "de",
          "locations": [
            "MENU_A"
          ]
        },
        {
          "language": "en",
          "locations": [
            "MENU_A"
          ]
        },
        {
          "language": "en",
          "locations": [
            "MENU_B"
          ]
        },
        {
          "language": "de",
          "locations": [
            "MENU_B"
          ]
        },
        {
          "language": "fr",
          "locations": [
            "MENU_B"
          ]
        },
        {
          "language": "en",
          "locations": [
            "MENU_C"
          ]
        },
        {
          "language": "fr",
          "locations": [
            "MENU_C"
          ]
        },
        {
          "language": "de",
          "locations": [
            "MENU_C"
          ]
        },
        {
          "language": "en",
          "locations": [
            "MENU_D"
          ]
        },
        {
          "language": "de",
          "locations": [
            "MENU_D"
          ]
        }
      ]
    }
  },
  "extensions": {
    "debug": [
      {
        "type": "DEBUG_LOGS_INACTIVE",
        "message": "GraphQL Debug logging is not active. To see debug logs, GRAPHQL_DEBUG must be enabled."
      }
    ]
  }
}

Now after updating to WP 6.1.1 the same query above instead gives these results:

{
  "data": {
    "menus": {
      "nodes": [
        {
          "language": "en",
          "locations": [
            "MENU_A"
          ]
        },
        {
          "language": "en",
          "locations": [
            "MENU_B"
          ]
        },
        {
          "language": "en",
          "locations": [
            "MENU_C"
          ]
        },
        {
          "language": "en",
          "locations": [
            "MENU_D"
          ]
        }
      ]
    }
  },
  "extensions": {
    "debug": [
      {
        "type": "DEBUG_LOGS_INACTIVE",
        "message": "GraphQL Debug logging is not active. To see debug logs, GRAPHQL_DEBUG must be enabled."
      }
    ]
  }
}

The issue being that the non-English menus are no longer returning via GraphQL queries.

I've tried instead querying by language like the following, but this does not work before or after 6.1.1:

query onlyGermanMenus {
  menus(where: {language: "de"}) {
    nodes {
      language
      locations
    }
  }
}

Before 6.1.1 this (^) query would return all menus and ignore the where, and after 6.1.1 this query is only returning English menus (same as if there wasn't a where query).

I'm guessing next steps are reviewing what may have changed in WordPress between WordPress 5.9 and Wordpress 6.1.1 that could've had this cascading effect. Will follow up if I can dig in further on that front.

@SmartyP
Copy link

SmartyP commented Apr 28, 2023

In case it is helpful to anyone, our workaround for this issue was to instead use the REST API with a menus extension such that we can query for all menu locations like this:
https://www.ourbackend.com/wp-json/menus/v1/locations

Then, once we know all the menu locations and languages we then query all those combinations in individual queries something like this:

query menuByLocationAndLanguage_${language}_${location} {
	menus(where: {location: ${location}, language: "${language}"}, first: 100) {
		nodes {
			language
			locations
			menuItems(where: {parentId: null}, first: 100) {
				nodes {
					parentId
					label
					url
				}
			}
		}
	}
}

We then aggregate all of those responses. Basically you can query for menus so long as you provide both location and language, so since those queries work we can still leverage them - we just have to nail down all the menus and languages with the REST API instead and make many individual queries instead of just 1 like before.

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