Skip to content

Commit

Permalink
feat: support meta query by array of values
Browse files Browse the repository at this point in the history
  • Loading branch information
natac13 committed Mar 8, 2022
1 parent ab7f535 commit d45a546
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion wp-graphql-meta-query.php
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,10 @@ public function register_types( $type_name, TypeRegistry $type_registry ) {
'type' => 'String',
'description' => __( 'Custom field value', 'wp-graphql' ),
],
'values' => array(
'type' => array( 'list_of' => 'String' ),
'description' => __( 'Custom field values, will override \'value\'', 'wp-graphql' ),
),
'compare' => [
'type' => $type_name . 'MetaCompareEnum',
'description' => __( 'Custom field value', 'wp-graphql' ),
Expand Down Expand Up @@ -321,7 +325,12 @@ public function map_input_fields( $query_args, $input_args ) {
}
foreach ( $meta_query['metaArray'] as $meta_query_key => $value ) {
$meta_query[] = [
$meta_query_key => $value,
$meta_query_key => array(
'key' => $value['key'],
'compare' => $value['compare'],
'type' => $value['type'],
'value' => $value['values'] ?? $value['value'],
),
];
}
}
Expand Down

0 comments on commit d45a546

Please sign in to comment.