import gql from 'graphql-tag' import { graphql, compose } from 'react-apollo' const GetProduct = gql` query GetProduct($productId: String, $apikey: String) { getProduct(productId: $productId, apikey: $apikey) { name product id brand url content { description fit_notes material care_instructions origin } categories image_urls skus { id inventory_status msrp_price sale_price shipping_surcharge attributes } } }` const GetProduct = gql` query GetProduct($apikey: String) { getProduct(apikey: $apikey) { categories } }` const withAppSyncProduct = compose( graphql(GetProduct, { name: 'getProduct', options: (ownProps) => ({ fetchPolicy: 'cache-and-network', variables: { productId: ownProps.productId, apikey: ownProps.apikey } }), props: (props) => { if (props.getProduct.error) console.log(props.getProduct.error) return props } }) ) export { GetProduct, GetProduct, withAppSyncProduct }