summaryrefslogtreecommitdiffstats
path: root/components/Item.js
diff options
context:
space:
mode:
Diffstat (limited to 'components/Item.js')
-rw-r--r--components/Item.js33
1 files changed, 33 insertions, 0 deletions
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 <p>Not ready</p>
+ console.log(this.props.findItem.Item);
+
+ if(this.props.loading) return <p>Loading...</p>
+ if(this.props.error) return <p>Error...</p>
+
+ const item = this.props.findItem.Item;
+ return (
+ <div>
+ <h2>Viewing {item.title}</h2>
+ </div>
+ )
+ }
+}
+
+const ComponentWithMutations = compose(
+ graphql(SINGLE_ITEM_QUERY, {
+ name: 'findItem',
+ // This comes from Props
+ options: ({ id }) => ({
+ variables: { id }
+ })
+ })
+)(Item);
+
+export default ComponentWithMutations;