Apolloを使っていてmutationを使ってデータの更新をした場合、updateを呼んでキャッシュを更新する必要がありました。ドキュメントに書いていたけど見つけるまでハマったのでメモ。
updateRelationship(relationship, variables) {
this.$apollo.mutate({
mutation: updateCompanyUserRelationship,
variables: variables,
// updateを呼んであげる
update: (store, {data: {todo}}) => {
const data = store.readQuery({query: userQuery, variables: {company_id: this.currentCompany.id}});
store.writeQuery({
query: userQuery,
variables: {
company_id: this.currentCompany.id
},
data
});
},
}).then(() => {
this.$notify({
group: 'foo',
title: 'ユーザー情報を更新しました。',
});
this.$refs['modal'].hide();
this.refresh();
});
},