Hi, I need help with:
1 - Use fetch links with Slices
2 - Need a way to do this with the Javascript Client
Is there a way to do this?
We're planning to move to Prismic very soon so quick response will be highly appreciated.
Thanks alot
Hi, I need help with:
1 - Use fetch links with Slices
2 - Need a way to do this with the Javascript Client
Is there a way to do this?
We're planning to move to Prismic very soon so quick response will be highly appreciated.
Thanks alot
Hello @thesrs02
Welcome to the Prismic community, and thanks for reaching out to us.
FetchLinks doesn't support retrieving any fields in the Slices or group. To retrieve fields from Slices, fetchLinks v2 works, which is known as graphQuery. And you can use it with javascript client too.
Find more details about how to implement graphQuery, in the following article:
Let me know if you have any further questions related to it.
Thanks,
Priyanka
Thanks @Priyanka
@thesrs02 Your welcome. Feel free to reach out to us if you have any questions.
Hi @Priyanka,
Thanks for your quick help with my earlier question. I need a little more help to make the graphQuery work.
My Structure:
Type => Slice (repeatable group) => Content Relationship => Product Type => Integration Field (shopify)
All I'm looking for is to get the body of linked products.
I'm getting this error: "Unable to parse fetch query Invalid fetch parsing Exception.\n\nThe fragment ...product_linkFields doesn't correspond to it's parent product"
Query:
Prismic Model (UI):
Can you help? Thanks in advance
Hello @thesrs02
Thanks for getting back to us.
There are two mistakes I found in your query:
...
before and Fields
after the name of the Custom Type. In your case, it should be ...productFields
not ...product_linkFields
The correct query looks like this:
{
collection {
body {
... on products_group {
repeat {
product {
... on product { //type of linked document
...productFields
}
}
}
}
}
}
}
It will solve your issue. Let me know if you have any other questions.
Thanks,
Priyanka
Thanks SO much @Priyanka!
It works. I can see all product fields in the response now.
Two questions:
1 - Is there a way to select specific fields from the response. I tried the followings but to no avail. I get a bad request error.
2 - Is there a way to get an unfolded response with this query? For example, having the products in the data field of the response body?
Attempt 1:
Attempt 2:
I must be missing something here but I would really appreciate your help with this if possible.
Thanks again for the awesome support!
Hello @thesrs02
It's not possible to fetch a specific field within an Integration field. It will retrieve everything inside IF.
Let me know if you have any other questions.
Thanks,
Priyanka
Thanks again @Priyanka
How would you do this kind of query inside of Nuxt within asyncData? So, I have a slice called FeaturedPages, which has repeatable fields of links to other pages. In this component of FeaturedPages I wanna be able to output data from each of the page added/linked, data such as the "FeaturedImage", which is a field in each page.
On the page, home in this instance, where this FeaturedPages slice is called, I've done like so
const page = await $prismic.api.getByUID('page', 'home', { fetchLinks: 'page.featured_pages' })
But page
returns without the data
object, from where I could've gotten to item.data.featuredImage
for example.
This is like a case of resolving all relationships/references on a page when it is queried. How do I do that in Nuxt?
Thanks.
Hi, @erik.israni, would you be able to take a look and unstuck me here? Would greatly appreciate. Thanks.
@kb1 - Maybe you'll find this helpful: Help | "ParsingError: Unable to parse fetch query Invalid fetch parsing Exception" - #2 by Phil