xxxxxxxxxx
add_action( 'graphql_register_types', function() {
register_graphql_field( 'PostCategory', 'categoryImage', [
'type' => 'MediaItem',
'resolve' => function( $post ) {
$image = get_post_meta( $post->databaseId, 'category_image_id' );
return ! empty( $image ) ? $image : null;
}
]);
});