wp-graphql / wp-graphql

:rocket: GraphQL API for WordPress

Home Page:https://www.wpgraphql.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unable to Make Menus and Menu Items public

hmingv opened this issue · comments

Description

We have no problem using the code below when using WP-Graphql V1.12.2.

Make Menus and Menu Items public

When I updated to V 1.22.1 it had no effect.

Steps to reproduce

  1. Install a clean WordPress installation
  2. Install WPGraphQL V1.12.2 version
  3. Add the code in the document to the theme or plug-in
  4. Test (everything is fine at this point)
  5. Update WPGraphQL to the latest version
  6. Test (failed)

Additional context

No response

WPGraphQL Version

1.22.1

WordPress Version

6.4

PHP Version

8.1

Additional environment details

No response

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.

After testing, I traced that the problem started appearing in version V1.22.0.

Depending on the theme we are using, the menu will not have its location set.

Does this have anything to do with it?

However, logged in users can view all menus, but they cannot be read publicly.

Thanks for reporting this @hmingv !

If you're tracing the change in behavior to v1.22.0, it's likely coming from #3043 . Whether this is a regression, intended behavior that requires updating that recipe, or the result of relying #3029 as a feature in your local query s another story.

In order for us to replicate and debug, can you please provide:

  1. The GraphQL query you are fetching (bonus points if you can also screenshot it with the results in the GraphiQL IDE)
  2. Your menu config (including the menu location it's assigned to, or whether it is unassigned).

Thanks!

Examples of unexpected results are as follows:

image

image

Use unauthorized account:

image

Use logged in account:

image

Now I downgrade the plugin:

image

Using an unauthorized account now gives the expected results:

image

GraphQL query:

query MenuItems {
  menuItems(first: 200, where: {parentDatabaseId: 0}) {
    nodes {
      id
      label
      uri
      childItems {
        nodes {
          id
          target
          childItems {
            nodes {
              id
              label
              target
              uri
              description
              cssClasses
              childItems {
                nodes {
                  id
                  label
                  uri
                  target
                  cssClasses
                }
              }
            }
          }
        }
      }
    }
  }
}