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

1 Like

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