diff options
| author | Wes Bos <wesbos@gmail.com> | 2018-05-24 15:19:21 -0400 |
|---|---|---|
| committer | Wes Bos <wesbos@gmail.com> | 2018-05-24 15:19:21 -0400 |
| commit | 072eca0e5038a7755ca9b2c94dfe1a0c3f110968 (patch) | |
| tree | a6c54e1503baf665ad0eeaeaad6d2a2b7ba3ba39 /frontend/components/Pagination.js | |
| parent | b294a6fa500b165aae86afbad5fce49a02314b0d (diff) | |
colocate queries and components
Diffstat (limited to 'frontend/components/Pagination.js')
| -rw-r--r-- | frontend/components/Pagination.js | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/frontend/components/Pagination.js b/frontend/components/Pagination.js index 380026d..8b25e06 100644 --- a/frontend/components/Pagination.js +++ b/frontend/components/Pagination.js @@ -3,8 +3,18 @@ import { Query } from 'react-apollo'; import styled from 'styled-components'; import Link from 'next/link'; import PropTypes from 'prop-types'; +import gql from 'graphql-tag'; import { perPage } from '../config'; -import { ALL_ITEMS_QUERY } from '../queries/queries.graphql'; + +const PAGINATION_QUERY = gql` + query itemsConnection($skip: Int = 0, $first: Int = 4) { + itemsConnection(orderBy: createdAt_DESC, first: $first, skip: $skip) { + aggregate { + count + } + } + } +`; const PaginationStyles = styled.div` text-align: center; @@ -31,7 +41,7 @@ const PaginationStyles = styled.div` `; const Pagination = props => ( - <Query query={ALL_ITEMS_QUERY}> + <Query query={PAGINATION_QUERY}> {({ data, loading, error }) => { if (loading || error) return null; const { aggregate } = data.itemsConnection; @@ -78,3 +88,4 @@ Pagination.propTypes = { }; export default Pagination; +export { PAGINATION_QUERY }; |
