From 072eca0e5038a7755ca9b2c94dfe1a0c3f110968 Mon Sep 17 00:00:00 2001 From: Wes Bos Date: Thu, 24 May 2018 15:19:21 -0400 Subject: colocate queries and components --- frontend/components/Items.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'frontend/components/Items.js') diff --git a/frontend/components/Items.js b/frontend/components/Items.js index 618cc84..394f16d 100644 --- a/frontend/components/Items.js +++ b/frontend/components/Items.js @@ -2,11 +2,25 @@ import React from 'react'; import { Query } from 'react-apollo'; import styled from 'styled-components'; import PropTypes from 'prop-types'; +import gql from 'graphql-tag'; import Pagination from './Pagination'; import Item from './Item'; import LoadingItem from './LoadingItem'; import { perPage } from '../config'; -import { ALL_ITEMS_QUERY } from '../queries/queries.graphql'; + +const ALL_ITEMS_QUERY = gql` + query ALL_ITEMS_QUERY($skip: Int = 0, $first: Int = 4) { + items(orderBy: createdAt_DESC, first: $first, skip: $skip) { + __typename + id + title + price + description + image + largeImage + } + } +`; const Items = styled.div` display: grid; @@ -57,3 +71,4 @@ class ItemList extends React.Component { } export default ItemList; +export { ALL_ITEMS_QUERY }; -- cgit v1.3