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 'next/link' class Pagination extends Component { render() { const { loading, error } = this.props.allItemsQuery; if(loading) return

Loading Item...

const meta = this.props.allItemsQuery._allItemsMeta; const { page } = this.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;