fetchLinks clarification

Hello,

I would like some clarification on what fetchLinks can and cannot do.
I have a document type landing which has

  • a title
  • an image
  • link to another landing (parent_landing)
  • many slice, one of those has a repeatable zone with links to other landing.

The doc states

fetchLinks can *not* retrieve the following fields:

* Embed
* GeoPoint
* Link
* Link to Media
* Rich Text (anything other than the first element)
* Any field in a Group or Slice

Can you please confirm those limitations apply for Group or Slice in the linked document ?
For example if i use fetchLinks=landing.title it seems that the titles from the landings referenced in my slice are in fact returned. It works with the image too.

Also it seems fetchLink works with Link.
I saw here that only a 2 lvl depth is allowed which only make sense if it can follow Links. I tried with fetchLinks=landing.parent_landing and it works (I can get the parent from the parent from the parent)

Error in documentation

Taking this opportunity to point some errors in the doc

  • param is fetchLinks not fetchlinks
  • to use multiple you have to pass fetchLinks=mymodel.myattribute1,mymodel.myattribute2 not [fetchLinks=mymodel.myattribute1,mymodel.myattribute2]

Sidenote

I cannot use graphQL nor GraphQuery because my landing model has 20 different slices and the GET request is longer than 2048chars.

Thanks

Nicolas

Hello @nicolas.braun

Thanks for reaching out to us.

We can not wholly rely on fetchLinks to get info from 2 documents deep. Sometimes with some repo, it does work, and sometimes it doesn't. That's why we usually recommend graphQuery. As we have already discussed in this thread: GraphQuery vs FetchLinks.

Error in the documentation:

  1. It's true, params should be fetchLinks.
  2. What version of @prismicio/client are you using? If it's V6, then surely it's
    fetchLinks: 'article.thumbnail,article.title'
    Find more detail in the Prismic client technical reference article.. You can switch the versions.

Thanks for pointing these out. I will pass this to my team to update the documentation.

I understand that graphQuery get request has limitations is not longer than 2048chars. You can reduce your string length by using line breaks with no spaces or tabs, as explained in the graphQuery article.

Let me know if you have any further questions.

Thanks,
Priyanka

Hi @Priyanka
Thanks for the clarification.

As per point 2 i'm currently testing in the Rest API directly and it only works without brackets.

best

Nicolas

Hello @nicolas.braun

Indeed, the fetchLinks query works without brackets. I'll let my team know to correct the doc.

Thanks for pointing this out to us.
Priyanka