📣 Note: To fetch and filter by meta values, their meta keys must be added to the allowlist.
We can retrieve meta values for custom posts, users, comments, and taxonomies (tags and categories), by querying fields
metaValue (for a single value) and
metaValues (for an array of values) from the corresponding type:
Custom posts, comments, users and taxonomies (tags and categories) can also be filtered by meta, using the
This input offers an enhancement over how the
meta_query args are provided (to functions
get_users, etc), in that type validations are strictly enforced in the GraphQL schema, and only the combinations that make sense are exposed.
This is accomplished by using the "oneof" input field
compareBy, which offers 4 possibilities. Depending on the chosen option, different operators can be used for the comparison:
In addition, when comparing by
key, there's no need to provide input
We can pass several items under
metaQuery, and decide if to do an
OR of their conditions by passing input
relation on the first item in the list.