Make Donations reactive

Co-authored-by: @alina-beck <alina.beck@mail.com>
This commit is contained in:
mattwr18 2019-11-12 13:26:30 +01:00
parent 982a02fc4f
commit a215093bc3
4 changed files with 4 additions and 5 deletions

View File

@ -1,13 +1,9 @@
import uuid from 'uuid/v4'
export default { export default {
Mutation: { Mutation: {
UpdateDonations: async (_parent, params, context, _resolveInfo) => { UpdateDonations: async (_parent, params, context, _resolveInfo) => {
const { driver } = context const { driver } = context
const session = driver.session() const session = driver.session()
let donations let donations
params.id = params.id || uuid()
const writeTxResultPromise = session.writeTransaction(async txc => { const writeTxResultPromise = session.writeTransaction(async txc => {
const updateDonationsTransactionResponse = await txc.run( const updateDonationsTransactionResponse = await txc.run(
` `

View File

@ -12,6 +12,7 @@ const driver = getDriver()
const updateDonationsMutation = gql` const updateDonationsMutation = gql`
mutation($goal: Int, $progress: Int) { mutation($goal: Int, $progress: Int) {
UpdateDonations(goal: $goal, progress: $progress) { UpdateDonations(goal: $goal, progress: $progress) {
id
goal goal
progress progress
createdAt createdAt
@ -22,6 +23,7 @@ const updateDonationsMutation = gql`
const donationsQuery = gql` const donationsQuery = gql`
query { query {
Donations { Donations {
id
goal goal
progress progress
} }

View File

@ -3,6 +3,7 @@ import gql from 'graphql-tag'
export const DonationsQuery = () => gql` export const DonationsQuery = () => gql`
query { query {
Donations { Donations {
id
goal goal
progress progress
} }

View File

@ -49,7 +49,7 @@ export default {
query() { query() {
return DonationsQuery() return DonationsQuery()
}, },
result({ data: { Donations } }) { update({ Donations }) {
const { goal, progress } = Donations[0] const { goal, progress } = Donations[0]
this.formData = { this.formData = {
goal, goal,