Wp Graphql Add Filter Acf

add_filter('graphql_post_object_connection_query_args', function ($query_args, $source, $args, $context, $info) {

 $post_object_id = $args['where']['postObjectId'];

 if (isset($post_object_id)) {
 $query_args['meta_query'] = [
 [
 'key' => 'myCustomField',
 'value' => $post_object_id,
 'compare' => '='
 ]
 ];
 }

 return $query_args;
}, 10, 5);

Leave a Comment