I am using a mutation with apollo and Vuejs to remove an entry for an event from my calendar. I need to retrieve the event id in an array.
deleteEvent: function () {
this.$apollo
.mutate({
mutation: MUTATION_entreePlanningDelete,
variable: {
id: this.id,
},
})
.then((data) => {
console.log(data);
});
},
in this function I appeal to the mutation request.
here is my array (this name : evenements), we can see the id. Can you tell me how to get it back?
I solved my problem
I did not pay attention, we just had to put in the event = parameter to the event selected in the calendar to add .id to say to retrieve the event id.
here is what had to be done on the template side
<v-btn text @click="deleteEvent(selectedEvent)"> Effacer </v-btn>
and here is what had to be done in the delete function
deleteEvent: function (event) {
this.$apollo
.mutate({
mutation: MUTATION_entreePlanningDelete,
variables: {
id: event.id,
},
refetchQueries: [{ query: QUERY_entreesPlanning }]
})
.then((data) => {
console.log(data);
});
},