How to filter by category name in custom post types?

Looking at the official wordpress documetation for WP_Query category
https://developer.wordpress.org/reference/classes/wp_query/#category-parameters
It should be something like

$args = array(
    'post_type'      => 'fruits',
    'posts_per_page' => 4,                    
    'category_name'  => 'apple' // category_name instead of category
);

$query = new WP_Query( $args ); 

This is assuming you actually use the category and not custom taxonomy
Also if actually refer to the slug and not name

If you would like to go by name then you’ll need to use tax_query

$args = array(
    'post_type'      => 'fruits',
    'posts_per_page' => 4,                    
    'tax_query'      => array(
        array(
            'taxonomy' => 'category',
            'field'    => 'name',
            'terms'    => 'apple',
        ),
    ),
);

$query = new WP_Query( $args ); 

This is also covered in the documentation for WP_Query
https://developer.wordpress.org/reference/classes/wp_query/#taxonomy-parameters