summaryrefslogtreecommitdiffstats
path: root/stepped-solutions/41/frontend/components/AddToCart.js
diff options
context:
space:
mode:
authorWes Bos <wesbos@gmail.com>2018-08-17 15:51:02 -0400
committerWes Bos <wesbos@gmail.com>2018-08-17 15:51:02 -0400
commitc3bbebfcfeed7a9b8c7470d7b48e12046d834e59 (patch)
tree05c50c931d0e709c640744387fbabe870658e9e7 /stepped-solutions/41/frontend/components/AddToCart.js
parent124f227a8235e08bddf8376e0b3d01d33c4414f3 (diff)
suuuup everyone
Diffstat (limited to 'stepped-solutions/41/frontend/components/AddToCart.js')
-rwxr-xr-xstepped-solutions/41/frontend/components/AddToCart.js29
1 files changed, 29 insertions, 0 deletions
diff --git a/stepped-solutions/41/frontend/components/AddToCart.js b/stepped-solutions/41/frontend/components/AddToCart.js
new file mode 100755
index 0000000..0625a9c
--- /dev/null
+++ b/stepped-solutions/41/frontend/components/AddToCart.js
@@ -0,0 +1,29 @@
+import React from 'react';
+import { Mutation } from 'react-apollo';
+import gql from 'graphql-tag';
+
+const ADD_TO_CART_MUTATION = gql`
+ mutation addToCart($id: ID!) {
+ addToCart(id: $id) {
+ id
+ quantity
+ }
+ }
+`;
+
+class AddToCart extends React.Component {
+ render() {
+ const { id } = this.props;
+ return (
+ <Mutation
+ mutation={ADD_TO_CART_MUTATION}
+ variables={{
+ id,
+ }}
+ >
+ {addToCart => <button onClick={addToCart}>Add To Cart 🛒</button>}
+ </Mutation>
+ );
+ }
+}
+export default AddToCart;