Hi Juanita,
I can't see 2 screenshots :(.
But I think the problem is the way you get query var. The get_query_var
should not be used in this situation as it gets the value from the main query. Please replace the code with:
$id = $query->get('relation_id');
$from = $query->get('relation_from');
$to = $query->get('relation_to');