Fix bug where surveys don't retain answers without reloading

This commit is contained in:
Ramon Wenger 2019-09-12 09:07:31 +02:00
parent 5c2ed30ccf
commit 23936ec6ae
1 changed files with 28 additions and 1 deletions

View File

@ -99,7 +99,34 @@
data: JSON.stringify(data)
}
}
}
},
refetchQueries: [{
query: SURVEY_QUERY,
variables: {id: this.id}
}],
// fixme: make the update work instead of refetching
// update: (store, {data: {updateAnswer: {answer}}}) => {
// // try {
// console.log(answer);
// const query = SURVEY_QUERY;
// const variables = {id: this.id};
// const queryData = store.readQuery({query, variables});
// console.log('queryData', queryData);
// if (queryData.survey) {
// console.log('answer.data', answer.data);
// queryData.survey.answer = {
// data: {
// ...data,
// __typename: 'AnswerNode'
// }
// };
// store.writeQuery({query, variables, data: queryData});
// }
// // } catch (e) {
// // console.error(e);
// // // Query did not exist in the cache, and apollo throws a generic Error. Do nothing
// // }
// }
});
});