Prismic Preview Linkresolver with Content Relationships

I have set up pages in Prismic to have a Content Relationship field in order to define a parent page, and form nested urls on the frontend.

I am using fetchLinks in my Prismic API queries in order to retrieve the Parent Page data, and that all works well.

However, I am running into an issue with Previews. Using Next.js and the prismic-javascript library, I have:

const url = await PrismicClient.getPreviewResolver(ref, documentId).resolve(
linkResolver,
'/'
)

The linkResolver in this case is not getting the data from the Content Relationship field needed in order to determine the page url. And, there doesn't seem to be a way to add in a fetchLinks option.

How can I get that Content Relationship data in the Preview document?

Hello Samantha, thanks for reaching out!

I understand why this being able to use fetchLinks in the getPreviewResolver method would be useful in this case, unluckily for the moment this is a limitation of the system. I'll add a task in our backlog to track this for future enhancements. And if/when we get news about it we'll post an update in this same thread.

For anyone curious, while the Content Relationship data isn't available in the preview doc, we came up with a workaround for our use case: We created a previewLinkResolver which first makes an additional api call for that parent page data, and then sends that through with the page doc to the regular linkResolver in order to get the page url

This issue has been closed due to inactivity. Flag to reopen.

We are facing a similar issue, where we have a homepage which references documents through content relationships and we want to be able to preview the homepage with new documents before publishing, is there any way to get unpublished content by id using await Client().getByIds without a refoption (or using the refOption from the parent article)

As an update for future reference, we started using the Releases feature, which seemed to have fixed the issue (if we both add the new documents + the homepage). The only issue is still that shareable links don't seem to work properly with releases