Properly typing Content Relationships

I am trying to build a mega menu for a my header but am running into a type error and was wondering if anyone had run into this and how you solved it? I am importing the generated types from @/prismicio-types.

interface IHeader {
  data: Simplify<HeaderDocumentData>;
}
Property 'data' does not exist on type 'ContentRelationshipField<"header_submenu">'.
  Property 'data' does not exist on type 'EmptyLinkField<"Document">'.

My client query looks like the following:

export default async function getHeaderSettings(
  client: Client<AllDocumentTypes>
): Promise<HeaderDocument<string>> {
  return client.getSingle('header', {
    graphQuery: `
          {
              header {
                  logo
                  menu {
                      label
                      is_link
                      link
                      submenu {
                          cta_image
                          menu {
                              item {
                                  ...itemFields
                              }
                          }
                      }
                  }
              }
          }
      `,
  });
}
const formatHeaderData = (data: Simplify<HeaderDocumentData>) => {
  const { menu, logo } = data;

  const formattedMenu = menu.length
    ? menu.map((item) => {
        return {
          label: item.label,
          is_link: item.is_link,
          link: item.link,
          submenu: {
            cta_image: item.submenu.data.cta_image,
            menu: item.submenu.data.menu.map((subMenuItem) => {
              return {
                menu_label: subMenuItem.item.data.menu_label,
                menu: subMenuItem.item.data.menu,
              };
            }),
          },
        };
      })
    : [];
  return {
    logo,
    menu: formattedMenu,
  };
};

Hi Nick,

Welcome to the community, I'll be happy to help with this :slight_smile:

The first thing I would like to check is the structure of your Custom Types so that I can check your Graph Query. Can you give me the URL of your repo so I can check this?

Thanks.