Fetching child pages by parentDocument

Hey everyone!

I'm using Prismic to create a website for a client, and in an effort to make their life as easy as possible, we created 3 tiers of pages. You can have your main page, then something like About would be under the main, and Our Team would be under About. I would like to be able to make a fetch call to get all tier 2 pages (like Our Team) under a tier 1 page (like About). It seems like both getAllByType() with filters as well as GraphQuery will not be able to do this, is there an efficient solution?

For example, the following code should work, but I get errors:

export async function getTierTwoPagesByParentUid(
    parentUid: string
): Promise<TierTwoPage[]> {
    const client = createClient();

    try {
        const pages = await client.getAllByType("tierTwoPage", {
            filters: [filter.at("my.tierTwoPage.parentPage.uid", parentUid)],
        });

        return pages;
    } catch (error) {
        console.error("Error fetching tier two pages:", error);
        return [];
    }
}

It's not possible to query across two levels like that. You can query "tier 2" pages by filtering on a reference field, but you can't directly query them under a "tier 1" page.

Could you clarify the structure of your page type and what exactly you're trying to query?