Link Resolver issues

Hello to everyone reading this, appreciate your response.
Could you please elaborate how actually linkResolver works with gatsby-source-prismic?
As far as I understand, during build process linkResolver is being used by the g-s-p, and url and document (content relation) fields are inserted via prismic-dom. Then these fields can be accessed in playground.

Indeed, during development run I see linkResolver resolving every page mentioned, but no fields are updated or inserted into dom. Of course I can attach linkResolver into every but this is not the way it should work, as far as I understand.

Any ideas what could be missing? I can see pages being resolved during build via console.log but where do I look for dom updates/injections?

Hello @sergey, thanks for reaching out!

The Link Resolver helps you generate the links to navigate to internal documents inside your website.

Since routing is specific to your site, you need to define a Link Resolver and provide it to some of the fields' methods. For example, if you have a Rich text field inside a Homepage document that links to a blog post, you need to pass the link resolver to the Rich text method. This way, when the link is rendered, it redirects to the correct page:

<RichText render={document.description.raw} serializeHyperlink={GatsbyLink}  />

Here is the RichText helper that renders your content correctly.

Had to clone working example of repo to find out what's the reason.
I placed schema file into folder but did not mention it gatsby-config, which lead to prismic not applying link resolver to the elements of this content type.

I see, and after you declared the path for the schemas in the gatsby-config, the problem went away?

Let us know if you need help with this or anything else.


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