Listing all entries in one section related to entries written by currentUser in another section The setup:

Section A (entries I want to list)

Section B


entries field (related to 1 entry from SectionA)


My goal is to list all entries from Section A, that are related to an entry in Section B  authored by the currentUser.

Right now what I'm doing is looping through all entries in Section B authored by the current user and querying/displaying the entry related to it, but it's way too inefficient and eats up a lot of database queries. Was hoping there's a more efficient way of doing this.

Not sure whether or not there's a way to achieve this sort of relation via a complex relatedTo or if I need to go another route.

Can provide additional information/clarification if anything is unclear.

Thanks
I think this is what you mean:

{% set sectionBEntries = craft.entries.section('B').authorId(currentUser.id) %}

{# 'relatedTo' works both ways, so we can use sectionBEntries 
    as input for relatedTo to get all section A entries that have 
    a relation to one of the section B entries by currentUser #}
{% set sectionAEntries = craft.entries.section('A').relatedTo(sectionBEntries) %}

{% for entry in sectionAEntries %}
    {{ entry.title }}
{% endfor %}