wp-graphql / wp-graphql-tax-query

Adds `tax_query` support to postObject connection queries using WP_Query
46 stars 16 forks source link

Missing Nested taxonomy query support #25

Open vinny17690 opened 3 years ago

vinny17690 commented 3 years ago

Hi @jasonbahl, Just wondering, does this plugin support nested tax queries (added example code below)? I have tried, but couldn't make it work. Looks like taxQuery is limited to only one relation field and one taxArray. Ideally, taxArray should accept the nested taxArray fields right?

Are there any plans to support it, i think it's very crucial to be able to narrow down results to exactly what we want instead of fetching all the data, and process on the frontend.

How do we write below query in WPGraphQL? Any help would be great. Thanks!

'tax_query' => array(
    'relation' => 'AND',
    array(
        'taxonomy' => 'post_tag',
        'terms' => array( 'gum', 'cereal', 'candy' ),
        'field' => 'slug',
        'operator' => 'IN',     
    )
    array(
        'relation' => 'OR',
        array(
            'taxonomy' => 'favorite_turtle',
            'terms' => array( 'Raphael' ),
            'field' => 'name',
            'operator' => 'NOT IN',
        ),
        array(
            'taxonomy' => 'favorite_soda',
            'terms' => array( 'RC' ),
            'field' => 'name',
        ),
    ),
),