wp-graphql/wp-graphql-smart-cache

When the Menu Model has been filtered to be public, menu's aren't being invalidated from the cache

jasonbahl opened this issue · 0 comments

Steps to reproduce:

Filter the "Menu" Models to make them public:

add_filter( 'graphql_data_is_private', function( $is_private, $model_name, $data, $visibility, $owner, $current_user ) {

	if ( 'MenuObject' === $model_name || 'MenuItemObject' === $model_name ) {
		return false;
	}

	return $is_private;

}, 10, 6 );

Create a menu, but don't assign it to a location (this would be a private menu by default).

Query for the menu:

{
  menu(id: "Menu with no Location", idType: NAME) {
    id
    name
    menuItems {
      nodes {
        id
        label
      }
    }
  }
}

See that you can get the menu as a public user:

CleanShot 2023-05-17 at 14 38 57

Enable Error Logging for WPGraphQL Smart Cache.

Update the menu you just queried.

PROBLEM

See that there are no purge events for the menu being edited, even though it's been filtered to be a Public model.

EXPECTATION

I would expect for a menu that's been filtered to be public to log an event such as:

[17-May-2023 20:35:37 UTC] (graphql_purge) key: dGVybTo0MA==, event: updated_nav_menu, user: 1, page: /wp-admin/nav-menus.php
[17-May-2023 20:35:37 UTC] (graphql_purge) key: skipped:term, event: updated_nav_menu, user: 1, page: /wp-admin/nav-menus.php