pre-fill donation input fields with data from query

This commit is contained in:
Alina Beck 2019-11-12 12:45:59 +03:00
parent cbab34e83c
commit bdeb208556
2 changed files with 24 additions and 1 deletions

View File

@ -1,5 +1,14 @@
import gql from 'graphql-tag'
export const DonationsQuery = () => gql`
query {
Donations {
goal
progress
}
}
`
export const UpdateDonations = () => {
return gql`
mutation($goal: Int, $progress: Int) {

View File

@ -16,7 +16,7 @@
</template>
<script>
import { UpdateDonations } from '~/graphql/Donations'
import { DonationsQuery, UpdateDonations } from '~/graphql/Donations'
export default {
data() {
@ -44,5 +44,19 @@ export default {
.catch(error => this.$toast.error(error.message))
},
},
apollo: {
Donations: {
query() {
return DonationsQuery()
},
result({ data: { Donations } }) {
const { goal, progress } = Donations[0]
this.formData = {
goal,
progress,
}
},
},
},
}
</script>