import gql from 'graphql-tag' import { graphql, compose } from 'react-apollo' const DeleteDeposit = gql` mutation DeleteDeposit($depid: Int) { deleteDeposit(depid: $depid) { } }` const GetDeposit = gql` query GetDeposit($depid: Int, $paymentMethod: String, $actorid: String, $refAccountid: Int, $operatorid: String, $amount: Float, $phone: Int, $pin: Int, $currency: String, $paymentContext: String) { getDeposit(depid: $depid, paymentMethod: $paymentMethod, actorid: $actorid, refAccountid: $refAccountid, operatorid: $operatorid, amount: $amount, phone: $phone, pin: $pin, currency: $currency, paymentContext: $paymentContext) { payid actorid amount ref_accountid payment_method operatorid phone pin currency payment_context } }` const GetDeposit = gql` query GetDeposit($payid: Int, $paymentMethod: String, $actorid: String, $refAccountid: Int, $operatorid: String, $amount: Float, $phone: Int, $pin: Int, $currency: String, $paymentContext: String) { getDeposit(payid: $payid, paymentMethod: $paymentMethod, actorid: $actorid, refAccountid: $refAccountid, operatorid: $operatorid, amount: $amount, phone: $phone, pin: $pin, currency: $currency, paymentContext: $paymentContext) { } }` const withAppSyncDeposit = compose( graphql(GetDeposit, { name: 'getDeposit', options: (ownProps) => ({ fetchPolicy: 'cache-and-network', variables: { depid: ownProps.depid, paymentMethod: ownProps.paymentMethod, actorid: ownProps.actorid, refAccountid: ownProps.refAccountid, operatorid: ownProps.operatorid, amount: ownProps.amount, phone: ownProps.phone, pin: ownProps.pin, currency: ownProps.currency, paymentContext: ownProps.paymentContext } }), props: (props) => { if (props.getDeposit.error) console.log(props.getDeposit.error) return props } }) graphql(DeleteDeposit, { props: (props) => ({ deleteDeposit: ownProps => props.mutate({ variables: { depid: ownProps.depid }, optimisticResponse: () => ({ deleteDeposit: { ...ownProps, __typename: 'Deposit', version: 1 } }) }) }) }) ) export { DeleteDeposit, GetDeposit, GetDeposit, withAppSyncDeposit }