Using Restrict Content Pro with WPGraphQL

With the latest minor release of WPGraphQL comes the Model Layer – a much cleaner way to interact with post objects before they’re sent down the pipe to the client.

I use Restrict Content Pro (RCP) to handle membership levels and appropriately restrict visibility of posts to users. Previously, I was hooking into the WP Query and checking a user’s metadata for their membership and subscription info. I then used this to add a taxonomy query clause to hide posts from being returned as required.

Now, however, there is a simple hook in WPGraphQL to simply set a post as private (I am using a tutorial CPT):