----Content Relationship Link
------Content Relationship Link
When I query the page using fetchLinks, I can't get to the content relationship links when trying to code the slice up. I believe that is a limitation of fetchLinks only being able to do this at the top level, and not from a slice.
However I am really struggling to achieve this with graphQuery too. Is the below possible?
I also tried looping through the slices to see if I could make another API call to fetch the 1st content link and then the 2nd, but I couldn't see a way to call this. The API only seems to have querying at the top level.
You need to have a content relationship field existing in the Slice connected to the custom type you want to get info from, and your query must match exactly your published structure, or it won't work.
Let me know if you have any more questions about this.
Thanks @Phil , I had remove the content relationship field hence the confusion. This is the first I've seen of the API browser. I added a new "Quote Author" relationship to a slice and this the output I managed to get when querying a particular page.
So I can see the quote_author, (which is where I believe I got to before). However what I cannot see is the actual properties of the Author custom type, which should be properties such as name, job title, avatar etc.
Is there a way to do this via fetchLinks or graphQuery? It would be great to get a reference to a definitive NextJS example showing how to do this as this seems to be quite vague in the docs.
The only issue I am getting now is that the query doesn't seem to return a fully-typed object based on my custom type. e.g. slice.primary.quote_author. should be of type "Author" but what is actually returned is ContentRelationshipField<"author">
Is there a correct way to force it so that it is of type AuthorDocument ?
This returns a type of BlogPostDocument, but again I cannot seem to get a typed AuthorDocument from this. Surely there must be a cleaner way to get this in typescript? I really do not want to have to resort to Any types.