import gql from 'graphql-tag' import { graphql, compose } from 'react-apollo' const GetSimilarProductRecommendation = gql` query GetSimilarProductRecommendation($context: similarProductContext, $productId: String, $color: String, $limit: Int, $referer: String, $abTestName: String, $abTestVariant: String) { getSimilarProductRecommendation(context: $context, productId: $productId, color: $color, limit: $limit, referer: $referer, abTestName: $abTestName, abTestVariant: $abTestVariant) { recommendations { productId productName productUrl productImageUrl brandName price { was now onSale } rating numReviews } } }` const withAppSyncSimilarProductRecommendation = compose( graphql(GetSimilarProductRecommendation, { name: 'getSimilarProductRecommendation', options: (ownProps) => ({ fetchPolicy: 'cache-and-network', variables: { context: ownProps.context, productId: ownProps.productId, color: ownProps.color, limit: ownProps.limit, referer: ownProps.referer, abTestName: ownProps.abTestName, abTestVariant: ownProps.abTestVariant } }), props: (props) => { if (props.getSimilarProductRecommendation.error) console.log(props.getSimilarProductRecommendation.error) return props } }) ) export { GetSimilarProductRecommendation, withAppSyncSimilarProductRecommendation }