Skip to content

Menu returning wrong items #3029

@rodrigo-martins

Description

@rodrigo-martins

Description

If there is no location menu saved yet, instead of a response being an empty array, it is returning an array of random menu items from another location

Steps to reproduce

  1. Register a menu (eg.: functions.php)
register_nav_menus(
     array(
   	  'primary' => esc_html__('Primary menu', 'my-blocks'),
          'secondary' => esc_html__('Secondary menu', 'my-blocks'),
   	  'contact'  => esc_html__('Contact menu', 'my-blocks'),
     )
 );
  1. Create items for primary and secondary menu on wordpress panel
  2. image
  3. image
  4. Go to GraphQL IDE and run:
query NewQuery {
  menuItems(where: {location: CONTACT}) {
    nodes {
      id
      label
    }
  }
}
  1. The result is an aleatory items from primary and secondary instead of empty array in "nodes"
{
  "data": {
    "menuItems": {
      "nodes": [
        {
          "id": "cG9zdDo0Ng==",
          "label": "Platform"
        },
        {
          "id": "cG9zdDo0Mw==",
          "label": "facebook"
        },
        {
          "id": "cG9zdDozNw==",
          "label": "Privacy Policy"
        },
      ]
    }
  }
}

Additional context

No response

WPGraphQL Version

Version 1.20.0

WordPress Version

6.4.2

PHP Version

8.2

Additional environment details

WPGraphQL Blocks - Version 2.1.1
Wordpress Multsites (directory)

Please confirm that you have searched existing issues in the repo.

  • Yes

Please confirm that you have disabled ALL plugins except for WPGraphQL.

  • Yes
  • My issue is with compatibility with a specific WordPress plugin, and I have listed all my installed plugins (and version info) above.

Metadata

Metadata

Assignees

Labels

status: in progressCurrently being worked ontype: bugIssue that causes incorrect or unexpected behavior

Type

No type

Projects

Status

✅ Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions