import React, { Component } from 'react'; import { graphql, gql, compose } from 'react-apollo'; import { ALL_ITEMS_QUERY } from '../queries'; import withData from '../lib/withData'; import { Link } from '../routes'; const Pagination = props => { const { loading, error } = props.allItemsQuery; if (loading) return

Loading Item...

; const meta = props.allItemsQuery._allItemsMeta; const { page } = props; const pages = Math.floor(meta.count / 3); return (

Page {page} of {pages} - {meta.count} total

{page > 1 ? ( ←Prev ) : null} {page <= pages ? ( Next → ) : null}
); }; const ComponentWithMutations = compose(graphql(ALL_ITEMS_QUERY, { name: 'allItemsQuery' }))(Pagination); export default ComponentWithMutations;