Get data from content relationship in slice on homepage

Hi!

I have a custom type called: Homepage. In this homepage custom type I use different slices that all have a content relationship with a custom type called Article.

My question is: How can I retrieve the Article custom type data from my slices that have the content relationship.

I use NextJS so I would like to get all the data and linked data in my page route and then send it to the slices. I just have no clue how to do this :confused:

@boudewijn_bout So here's how I achieve what I believe you're asking about:

// [...uid].js
// all the jsx stuff goes here

export async function getStaticProps({params, previewData}) {
  const client = createClient({previewData})
  const page = await client.getByUID(
    'page',
    params.uid[params.uid.length -1],
    {
      fetchLinks: [
        'subdirectory',
        'boardmember.name',
        'boardmember.image',
      ]
    }
  )
}

Now the slices will have access to those content relationships. See here: Fetch Data in Next.js - Documentation - Prismic

Hello @boudewijn_bout

fetchLinks can not retrieve the fields in slices. To retrive fields from slices, you need to use graphQuery.
Learn more about graphQuery here: GraphQuery API Option Technical Reference - Documentation - Prismic.

Thanks,
Priyanka