wp-graphql / wp-graphql-smart-cache

Smart Caching & Cache Invalidation for WPGraphQL

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Over-purging terms

jasonbahl opened this issue · comments

Currently WPGraphQL is over-purging terms.

When a published post that already has connections to terms is updated, the hook edited_term_taxonomy fires, even though the relationship to the term hasn't changed and the term itself isn't being edited.

WPGraphQL smart cache is still reacting to this hook and is purging tags, even though they shouldn't be purged.

Steps to Reproduce

With WPGraphQL and WPGraphQL Smart Cache active:

  1. Publish a post with one or more categories assigned.
  2. Paste in this code and monitor the error logs:
add_action( 'graphql_purge', function( $key ) {
	error_log( 'graphql_purge: ' . $key );
});
  1. Update the post, but don't change the categories, just change the title of the post.
  2. See in the error logs that the category(s) were purged (this is not intended behavior)

I would expect the terms to only be purged if their relationship to a public object was changed.