From 1450e579c67e3d969cb099dfe6c1cefd1e313fb5 Mon Sep 17 00:00:00 2001 From: Wes Bos Date: Fri, 15 Sep 2017 14:26:13 -0400 Subject: yep --- components/Item.js | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 components/Item.js (limited to 'components/Item.js') diff --git a/components/Item.js b/components/Item.js new file mode 100644 index 0000000..66ca66f --- /dev/null +++ b/components/Item.js @@ -0,0 +1,33 @@ +import React, { Component } from 'react' +import { graphql, gql, compose } from 'react-apollo' +import { SINGLE_ITEM_QUERY } from '../queries'; +import withData from '../lib/withData'; + +class Item extends Component { + render() { + if(!this.props.findItem.Item) return

Not ready

+ console.log(this.props.findItem.Item); + + if(this.props.loading) return

Loading...

+ if(this.props.error) return

Error...

+ + const item = this.props.findItem.Item; + return ( +
+

Viewing {item.title}

+
+ ) + } +} + +const ComponentWithMutations = compose( + graphql(SINGLE_ITEM_QUERY, { + name: 'findItem', + // This comes from Props + options: ({ id }) => ({ + variables: { id } + }) + }) +)(Item); + +export default ComponentWithMutations; -- cgit v1.3