Like what we’re doing? Star us on GitHub!

How to use internal links in Rich Text without overloading the client with data?

Kikky
last month
1 1

Hello!

I want to use the functionality of internal links to other documents in the project. This is very handy so that I don't lose links when the document slug changes or the URL structure changes, for example. But along with the required fields of the target page (urlSlug, title), I even get the whole Rich-text document on the client ... how can I bypass this to get only the required fields?

image

how can I exclude text field from getting it? I use GraphQL to get data from server.

Should I filter it on the server? Is it the only solution?

Thank you in advance!

  • Kikky
    last month

    As I understand, I need to sepcify correct value for maxDepth property of the relationship field in link native element? How can I do it? Or I have to override somehow native link element?

    2 replies
  • JessChowdhury
    Payload Team
    last month

    Hi @Kikky - yes you'll want to set a maxDepth on the relationship field which looks like this:

    {
      name: 'link',
      type: 'relationship',
      relationTo: ['posts', 'pages'],
      maxDepth: 1,
    }

    You may want to reduce it further to maxDepth: 0, try updating these and comparing your returned data.

  • evelynhathaway
    3 weeks ago

    I don't think this solution is possible. I created #2166 to track the capability that would solve the author's request.

Open the post
Continue the discussion in GitHub
Can't find what you're looking for?
Get help straight from the Payload team with an Enterprise License.Learn More