Trouble with GraphQuery and FetchLinks

Hello,

I'm having issues fetching data from linked documents and I've tried both the GraphQuery and FetchLinks methods but do not see the data returned. Here are my examples on my 'case_studies' custom type.

FetchLinks

export async function getStaticProps() {
  const home = (await Client().getByUID('page', 'home', { fetchLinks : ['case_study.title',  'case_study.overview_description'] }))
  return {
    props: {
      home,
    },
  }
}

GraphQuery

const homeQuery = `{
  homepage {
    data {
      uid
      body {
        ... on PrismicPageDataBodyContentCarousel {
          non-repeat {
            title
          }
          repeat {
            title
            case_study {
              document {
                ... on PrismicCaseStudies {
                  data {
                    title
                    overview_description
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}
`
export async function getStaticProps() {
  const home = (await Client().getByUID('page', 'home', { 'graphQuery': homeQuery }))
  return {
    props: {
      home,
    },
  }
}

Here's what is returned in both instances:
Screen Shot 2022-01-05 at 11.09.57 AM

Any help is much appreciated!
-Lee

Turns out I had named the wrong custom type in my FetchLinks version and below is working:

const home = (await Client().getByUID('page', 'home', { fetchLinks : 'case_studies.title' }))

I'm still curious to know what I'm doing with the GraphQuery version.

Hi Lee,

I'm glad you figured this out, although I'm not sure what you mean when you say "I'm still curious to know what I'm doing with the GraphQuery version.", can you give me more details?

Thanks.

Hi @Phil ,

When I tried using GraphQuery, I found that the data I was trying to fetch wasn't returned. I was attempting to get the title and overview_description fields from my Case Study type. The below code, didn't provide any errors, but the title and overview_description still weren't available on the case_study link field (as seen in the screenshot in my original post)

const homeQuery = `{
  homepage {
    data {
      uid
      body {
        ... on PrismicPageDataBodyContentCarousel {
          non-repeat {
            title
          }
          repeat {
            title
            case_study {
              document {
                ... on PrismicCaseStudies {
                  data {
                    title
                    overview_description
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}
`
export async function getStaticProps() {
  const home = (await Client().getByUID('page', 'home', { 'graphQuery': homeQuery }))
  return {
    props: {
      home,
    },
  }
}

Thanks,
-Lee

Hello Lee,

Phil is off today. I'd love to debug the issue. Could you please send me the name of your Prismic repo URL? You can send me by private message though.

Thanks,
Priyanka

Hi Lee, there's a few things I've noticed.

In you getByUID query the type is page, but then in the GraphQuery you specify homepage. You also specifiy data in your GraphQuery which isn't necessary.

So it looks like the GraphQuery wasn't built correctly.

Thanks.