Help with graphquery

I have the following query:

const home = await client.getSingle("homepage", {
    graphQuery: `
    {
      homepage {
        ...homepageFields
        slices {
          ...on boxes {
            variation {
              ...on default {
                primary {                  
                  ...primaryFields
                }
              }
            }
          }
        }
      }
    }
    `,
  });

  const boxes = home.data.slices.find((slice) => slice.slice_type === "boxes");

  console.log("boxes", boxes?.primary.items[0]);

This is the output that i get when running the above:

[next] boxes {
[next]   title: 'Drept Societar și Comercial',
[next]   description: 'Oferim consultanță companiilor în fiecare etapă a evoluției lor. Indiferent dacă ajutăm firme să pătrundă pe piața românească sau să se adapteze specificului juridic local, avem o înțelegere profundă a pieței și contextului de afaceri din România.',
[next]   icon: 'gavel',
[next]   page: {
[next]     id: 'ZyP6GxEAAC4AOKt6',
[next]     type: 'page',
[next]     tags: [],
[next]     lang: 'ro-ro',
[next]     slug: 'drept-societar-si-comercial',
[next]     first_publication_date: '2024-10-31T21:43:57+0000',
[next]     last_publication_date: '2024-10-31T21:45:33+0000',
[next]     uid: 'drept-societar-si-comercial',
[next]     url: '/drept-societar-si-comercial',
[next]     link_type: 'Document',
[next]     isBroken: false
[next]   }
[next] }

And here is the issue: I want to get additional data of the linked page. For example title and slices.

So what I tried was the following:

      homepage {
        ...homepageFields
        slices {
          ...on boxes {
            variation {
              ...on default {
                primary {
                  page {
                    ...pageFields
                  }
                }
              }
            }
          }
        }
      }
    }

But I get an error:

[next] Unable to find page in primary
[next]     at async Index (page.tsx:50:18)

I tried every possible combination, I give up, I don't have a clue how to set this query up :(

Not sure if this will help @tudor2004 but it's worth a shot. When I am pulling my hair out with graphQueries, I switch to fetchLinks to see if it gets me what I want. Once I see what happens there, I'll determine if it's worth it to me to use the graphQuery process.

Below is a graphQuery that works for me. The withSubMenu variation queries a document type of sub_menu from which I pull its slices:

const layout = await client.getSingle('site_layout', {
    // fetchLinks: ['sub_menu.slices'], note this is here from when I pulled my hair out
    graphQuery: `
    {
      site_layout {
        call_label
        call_link
        logo
        slices {
          ...on menu_item {
            variation {
              ...on default {
                primary {
                  label
                  link
                }
              }
              ...on withSubMenu {
                primary {
                  label
                  sub_menu {
                    slices
                    slices1
                    slices2
                  }
                }
              }
            }
          }
        }
      }
    }
    `,
  })