import gql from 'graphql-tag' import { graphql, compose } from 'react-apollo' const GetPlace = gql` query GetPlace() { getPlace() { } }` const PutPlace = gql` mutation PutPlace($place: PlaceInput! ) { putPlace(place: $place) { } }` const withAppSyncPlace = compose( graphql(GetPlace, { name: 'getPlace', options: (ownProps) => ({ fetchPolicy: 'cache-and-network', variables: { } }), props: (props) => { if (props.getPlace.error) console.log(props.getPlace.error) return props } }), graphql(PutPlace, { props: (props) => ({ putPlace: ownProps => props.mutate({ variables: { place: ownProps.place }, optimisticResponse: () => ({ putPlace: { ...ownProps.place, __typename: 'Place', version: 1 } }) }) }) }) ) export { GetPlace, PutPlace, withAppSyncPlace }