fix(answers): fix answers route crashing

this commit fixes the crash that was caused by change in a couple of properties from upstream

BREAKING CHANGE: old fetcher may or may not work

fix: https://github.com/zyachel/quetre/issues/101
This commit is contained in:
zyachel 2023-04-23 19:10:42 +05:30
parent 0ebaec7065
commit b8a0b9fcad

View file

@ -38,13 +38,16 @@ const answersFetcher = async (resourceStr, lang) => {
rawData.question = matchedPart.question;
// primary answer block
} else if (matchedPart.question?.answers?.edges) {
} else if (
matchedPart.question?.answers?.edges &&
matchedPart.question.answers.edges[0].node.answer.content
) {
rawData.answers.push(matchedPart.question.answers.edges[0].node.answer);
// other answer blocks
} else if (
// eslint-disable-next-line no-underscore-dangle
matchedPart.node?.__typename === 'QuestionRelevantAnswerItem2'
matchedPart.node?.__typename === 'QuestionAnswerItem2'
) {
rawData.answers.push(matchedPart.node.answer);