diff options
| author | Wes Bos <wesbos@gmail.com> | 2017-09-15 14:26:13 -0400 |
|---|---|---|
| committer | Wes Bos <wesbos@gmail.com> | 2017-09-15 14:26:13 -0400 |
| commit | 1450e579c67e3d969cb099dfe6c1cefd1e313fb5 (patch) | |
| tree | 5c255968082c16452f1dc8245dbbb890f91dce87 /components/Item.js | |
| parent | 7af74ff8988961c988f03c95961b70c2918521ae (diff) | |
yep
Diffstat (limited to 'components/Item.js')
| -rw-r--r-- | components/Item.js | 33 |
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; |
