Replacing fetchLinks with graphQuery

Hi,

I'm currently using Next.js with the slice machine and have a slice called "FAQSection" which has links to the custom type "FAQ". I also have different custom types for different types of pages, and for each page I use the same query, but change the type and uid like so:

export const PAGE_LINKS = [
  "faq.questionName",
  "faq.acceptedAnswerText",
];

prismicDocument = await client.getByUID(type, uid, {
  fetchLinks: PAGE_LINKS,
  lang: locale,
});

I'm running into the problem where fetchLinks does not fetch more than 1 paragraph for a rich text field (acceptedAnswerText), so apparently the solution is to use graphQuery instead. I've tried doing this like so:

export const graphQuery = `
  {
    pageType1 {
      slices {
        ...on faq_section {
          variation {
            ...on default {
              primary {
                ...primaryFields
              }
              items {
                ...itemsFields
                faq {
                  acceptedAnswerText
                  questionName
                }
              }
            }
          }
        }
      }
    }
  }
`;

but am encountering some problems.

  1. It does not load other slices, do I have to add each one manually here?
  2. It is not loading stuff like SEO metadata. It is not clear
  3. I have loads of types apart from "pageType1" that have this FAQ section slice, do I really need to add each one here?

Ideally I would just keep using fetchLinks and have it fetch more paragraphs for the rich text (why is this even a thing?), but since that is seemingly impossible, can you guys help out with this?

Hello @amos

Thanks for reaching out to us.

As you figured out already that fetchLinks are limited to fetching the first element of the Rich Text field. It doesn't fetch anything other than the first element. You need to use graphQuery for deep fetching that you are already implementing. To retrieve all Slices and Custom Types, you need to mention each Slice and Custom type name in your graphQuery.
Ensure that request URLs to the Rest API are limited to 2048 characters. You can reduce your string length using line breaks with no spaces or tabs or a white space removal tool.

Let me know if you have any further questions.

Thanks,
Priyanka