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/UpdateItem.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'frontend/components/UpdateItem.js') diff --git a/frontend/components/UpdateItem.js b/frontend/components/UpdateItem.js index ecaac75..08ba254 100644 --- a/frontend/components/UpdateItem.js +++ b/frontend/components/UpdateItem.js @@ -1,10 +1,19 @@ import React, { Component } from 'react'; import { Query, Mutation } from 'react-apollo'; import PropTypes from 'prop-types'; -import { SINGLE_ITEM_QUERY, UPDATE_ITEM_MUTATION } from '../queries/queries.graphql'; +import gql from 'graphql-tag'; +import { SINGLE_ITEM_QUERY } from './SingleItem'; import Form from './styles/Form'; import Error from './ErrorMessage'; +const UPDATE_ITEM_MUTATION = gql` + mutation updateItem($id: ID!, $title: String, $description: String, $price: Int) { + updateItem(id: $id, description: $description, title: $title, price: $price) { + id + } + } +`; + class UpdateItem extends Component { static propTypes = { id: PropTypes.string.isRequired, @@ -18,7 +27,6 @@ class UpdateItem extends Component { if (type === 'number') { value = parseInt(value); } - console.log('Saving to state'); const item = { ...this.state.item }; item[name] = value; this.setState({ item }); @@ -94,3 +102,4 @@ class UpdateItem extends Component { } export default UpdateItem; +export { UPDATE_ITEM_MUTATION }; -- cgit v1.3