我有突变
mutation createQuoteLineMutation {
createQuoteLine {
quoteLine {
name
price
product {
name
}
}
}
}
我的更新程序功能如下。
updater: (store) => {
const payload = store.getRootField('createQuoteLine');
const newQuoteLine = payload.getLinkedRecord('quoteLine');
const quote = store.getRoot().getLinkedRecord('getQuote');
const quoteLines = quote.getLinkedRecords('quoteLines') || [];
const newQuoteLines = [...quoteLines, newQuoteLine];
quote.setLinkedRecords(newQuoteLines, 'quoteLines');
}
这第一次工作得很好,但是所有先前添加的quoteLines 随之发生的突变都会更改为新的我假设这是因为newQuoteLine 一直指向同一个对象。
在更新程序函数的末尾添加以下行 unlink quoteLine from createQuoteLine 也不起作用。
payload.setValue(null, 'quoteLine');
非常感谢这方面的任何帮助。