react-js-buy example: checkout.totalTax and checkout.totalPrice do not exist on type 'Cart'
princefishthrower opened this issue · 1 comments
In the react-js-buy
example (https://github.com/Shopify/storefront-api-examples/tree/master/react-js-buy), in component Cart (https://github.com/Shopify/storefront-api-examples/blob/master/react-js-buy/src/components/Cart.js) there is usage of this.props.checkout.totalTax
and this.props.checkout.totalPrice
.
I've recently done a TypeScript implementation following the code in react-js-buy
, but I notice in the typing of this.props.checkout
, which is of ShopifyBuy.Cart
type, that totalTax
and totalPrice
are no longer there. (Only subtotalPrice
remains.)
I also don't find totalTax
and totalPrice
anywhere in the Shopify Buy SDK docs either (https://shopify.github.io/js-buy-sdk/)
I'm wondering if the patterns in react-js-buy
are altogether deprecated, or not the best way of connecting to the Shopify API anymore - I notice this example hasn't been updated in a year, while others example folders like the react-apollo
, react-graphql-client
, and react-hooks-apollo
have been updated within the last few months.
Any pointers or explanation would be greatly appreciated!
Our schema has evolved since these original examples were created so yes they are slightly outdated and use some deprecated fields.
In the case of totalTax
and totalPrice
there are newer "v2" fields: totalTaxV2
and totalPriceV2
. Our reference docs always show the latest schema: https://shopify.dev/docs/storefront-api/reference/object/checkout/?api[version]=2020-07
The JS Buy SDK has also been updated to use these new fields: https://github.com/Shopify/js-buy-sdk/blob/28c85805ee21bdebf9611da6b92c39858b15dc0a/src/graphql/CheckoutFragment.graphql, just not the examples here.
What client you should use really depends on your use case and familiarity with the tools. Apollo is probably the most popular JS GraphQL client so that's always a good starting point.