diff options
| author | Wes Bos <wesbos@gmail.com> | 2018-01-30 12:41:01 -0500 |
|---|---|---|
| committer | Wes Bos <wesbos@gmail.com> | 2018-01-30 12:41:01 -0500 |
| commit | cd0b07b3adb36fb5ec098f9e511ab45d774fee7b (patch) | |
| tree | a203e5010219ccea1acc6bbd2c0a4bcfa0a78615 /frontend/components/Count.js | |
| parent | 0a1648bf47490b312169c531aeb51ef4725e8d2e (diff) | |
Move to Prisma Backend
Diffstat (limited to 'frontend/components/Count.js')
| -rw-r--r-- | frontend/components/Count.js | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/frontend/components/Count.js b/frontend/components/Count.js new file mode 100644 index 0000000..800a902 --- /dev/null +++ b/frontend/components/Count.js @@ -0,0 +1,37 @@ +import React, { Component } from 'react' +import { graphql, gql } from 'react-apollo' + +import { ALL_ITEMS_QUERY } from '../queries'; + +class Count extends Component { + + render() { + + // 1 + if (this.props.allLinksQuery && this.props.allLinksQuery.loading) { + return <div>Loading</div> + } + + // 2 + if (this.props.allLinksQuery && this.props.allLinksQuery.error) { + return <div>Error</div> + } + + // 3 + const itemsToRender = this.props.allLinksQuery.allItems + + return ( + <div> + <h1>There are {itemsToRender.length} items for sale</h1> + </div> + ) + } + +} + +// 1 + +// We export the graphQL HOC - this will fetch the data and inject it into the Count compeont via props + +export { ALL_ITEMS_QUERY } +export default graphql(ALL_ITEMS_QUERY, { name: 'allLinksQuery' }) (Count) |
