Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Using Storefront API to Get Product Recommendations.

Using Storefront API to Get Product Recommendations.

John1994
Visitor
1 0 2

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?

Screen Shot 2020-11-25 at 11.19.36 AM.png

Screen Shot 2020-11-25 at 11.30.44 AM.png

Reply 1 (1)

mani_HL
Shopify Partner
5 0 2

Hi @John1994 

Use 

query productRecommendations ($productIdID!,$variantsFirstInt = 1$imagesFirstInt = 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
              }           
            } 
          }
        }     
      }
}