Using Storefront API to Get Product Recommendations

Hi

I’m creating a react native app that is connected to a shopify store, and i’m using Storefront api to get all the data i want (collection, products…).

I was trying to get the product Recommendations by the product id using QueryRoot as described in the documentation but i wasn’t able to build the query.

I got this error: “Field ‘productRecommendation’ doesn’t exist on type ‘QueryRoot’”

Anyone does know how to build the query or if there an alternative way to get product recommendations?

Hi @John1994

Use

query productRecommendations ($productId: ID!,$variantsFirst: Int = 1, $imagesFirst: Int = 5){
productRecommendations (productId: $productId) {
description
handle
id
images(first: $imagesFirst) {
edges {
node {
originalSrc
altText
}
}
}
priceRange {
maxVariantPrice {
amount
}
minVariantPrice {
amount
}
}
productType
tags
title
variants(first: $variantsFirst) {
edges {
node {
sku
availableForSale
id
compareAtPriceV2 {
amount
currencyCode
}
priceV2 {
amount
currencyCode
}
title
image {
originalSrc
altText
}
}
}
}
}
}