Homepage
Link to WPGraphQL on Github
Link to WPGraphQL on WordPress.org

WPGraphQL Meta Query

This FREE plugin filters the connections for Posts and Post Types to allow for advanced querying using meta filters.

Querying by meta can be dangerous, do this feature will likely not be in the core plugin, but if you need it:

Official Plugin

View Plugin on Github
Plugin README

WPGraphQL Meta Query

This plugin adds Meta_Query support to the WP GraphQL Plugin for postObject query args.

Why is this an extension and not part of WPGraphQL?

Meta Queries can be expensive and have been known to actually take sites down, which is why they are not part of the core WPGraphQL plugin.

If you need meta queries for your WPGraphQL system, this plugin enables them, but use with caution. It might be better to hook into WPGraphQL and define specific meta queries that you know you need and are not going to take your system down instead of allowing just any metaquery via this plugin, but you could use this plugin as an example of how to hook into WPGraphQL to add inputs and map those inputs to the WPQuery that gets executed.

Pre-req's

Using this plugin requires having the WPGraphQL plugin installed and activated. Requires WPGraphQL version 0.0.15 or newer.

Activating / Using

Activate the plugin like you would any other WordPress plugin.

Once the plugin is active, the metaQuery argument will be available to any post object connectionQuery (posts, pages, custom post types, etc).

Example Query

Below is an example Query using the metaQuery input on a posts query. (Go ahead and check things out in GraphiQL)

This will find posts that have some_value as the value of the postmeta field with the key of some_key AND also DOES NOT have some_other_value as the value for the postmeta key some_other_key

The same query in PHP using WP_Query would look like: