Closed teetlaja closed 2 years ago
@teetl6 thanks for reporting. Let me see if I can replicate this behavior.
@teetl6 thanks for reporting. Let me see if I can replicate this behavior.
Thanks, if additional information needed, let me know. WordPress version was 5.7 and request was made with WPGraphQL IDE.
@teetl6 was it working as expected and suddenly had a change in behavior? If so, do you know what version of WPGraphQL was working and what version it stopped working?
@teetl6 was it working as expected and suddenly had a change in behavior? If so, do you know what version of WPGraphQL was working and what version it stopped working?
No, this is on clean install and appeared with WPGrahpQL 1.2.8 and 1.3.x as well - updating didn't resolve the problem.
Ok, thanks for the information. Looking into it.
I've tried now many things - deleted menus and menuItems, created them again, turned off WPGraphQL plugin (with data erasing enabled) etc etc and still nothing new. Except debugging gives me this:
"errors": [
{
"message": "Field \"menuItems\" argument \"where\" requires type MenuLocationEnum, found \"PRIMARY\"; Did you mean the enum value PRIMARY?",
"extensions": {
"category": "graphql"
},
"locations": [
{
"line": 2,
"column": 31
}
]
}
],
My query was copied from wpgraphql site
query MENU_ITEMS {
menuItems(where: {location: "PRIMARY"}) {
nodes {
key: id
parentId
title: label
url
}
}
}
Thing is that now i even can't choose menu location which to query.
Theme is WordPress Twenty twenty-one child theme created with Child theme configuratior.
But when i removed " from location, then i got returned all menu Items, even if i change menu location.
@teetl6 try changing your query to:
query MENU_ITEMS {
menuItems(where: {location: PRIMARY}) {
nodes {
key: id
parentId
title: label
url
}
}
}
The key change being "PRIMARY"
to PRIMARY
without the quotes.
When an ENUM value is used within the Query string, it shouldn't have the quotes around it, otherwise it evaluates as a String, and not an Enum.
Hello @teetl6 , I'm curious about the "locations": null
you are seeing.
Can you use wp-cli to query the menu locations? Like
wp menu location list
Hello @teetl6 , I'm curious about the
"locations": null
you are seeing. Can you use wp-cli to query the menu locations? Likewp menu location list
@markkelnar It responds me this - bottom-menu is declared by me in Child theme configuration. Parent theme is Twenty-twentyone +-------------+----------------+ | location | description | +-------------+----------------+ | primary | Primary menu | | footer | Secondary menu | | bottom-menu | Bottom menu | +-------------+----------------+
@jasonbahl and @markkelnar I've tried previous steps but found out that IF I deactivate WPGraphQL WPML extension, the problem goes away. If i'm activating this again, it comes back.
If WPGraphQL WPML extension is active then all menu items are displayed no matter if the where: location: is added in query or not.
@teetl6 interesting. Thanks for the added context about WPML. We've had other reports with WPML causing problems. I've applied for a developer license for WPML so I can try and help debug issues, but I would also recommend opening an issue on their end. Their plugin is clearly altering behavior of menus in unexpected ways.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
This issue has been automatically closed because it has not had recent activity. If you believe this issue is still valid, please open a new issue and mark this as a related issue.
Closing as duplicate of #1305
I'm getting the exact same behaviour. When trying to query for a menu using location in where clause and that location has no menu assigned to it - I'm getting all menus by default. I've disabled all plugins except for WPGraphQL and it still kept happening. What could be the cause here?
@furai please open a new bug report with all the requested information so we can give it our full attention 🙏 (Unless this is an issue with WPML, in which case you can follow progress in #1305 )
So it always worked for me but for some reason menuItems is returning all Menu items from everywhere. My query is
And my response still is>
I have registered one extra nav but i suppose this doesn't affect.
I don't have any plugins which could affect navigation menus. All plugins and examples are from WPGraphQL docs.
If i use menu.menuItems request hierarchy then i can get right menu but singe page is going to have 7 translations, i can't afford those mistakes - i need to query menu items by location. I'm having WPGraphQL up-to-date.