I want to update or refetch data in apollo query that used in a method (not apollo object). the thing is i wanted to query and update that query after specific event, so i couldn't use apollo object directly in in my code.
methods: {
async fetchEvents() {
const { data } = await this.$apollo.query({
query: gql`
query(
$someThing: Int,
) {
events (
someThing: $someThing,
) {
total
items {
...
}
}
}
`,
variables() {
return {
...
};
},
});
this.data = data;
},
},
watch: {
'items.view.organizerId': function callback() {
this.fetchEvents();
},
eventsSearchInputVal: function callback() {
this.fetchEvents();
},
'pagination.statusFilter': function callback() {
this.fetchEvents();
},
},
in conclusion when pagination.statusFilter
or eventsSearchInputVal
or items.view.organizerId
in watch
got changed the query should refetch. in this code nothing happen when those variables get changed.