问题描述
我在我的应用程序的循环中使用来自 Apollo useMutation 钩子的 mutate 函数。它运行良好,但我需要将实际 GraphQL 调用中未使用的变量从循环范围传递到 onCompleted 回调,而且我在文档或论坛中没有看到任何策略。
目前的结构如下:
变异和回调
const [getBalance] = useMutation(BALANCE_MUTATION,{
onCompleted: ({ data }) => {
// I would like to do something with data and the original orderLine here
},});
循环和调用:
orderLines.forEach((orderLine,i) => {
getBalance({
variables: {
input: {
orderNumber: orderLines.orderNumber,currency: orderLines.currency,},});
});
有人这样做过或知道推荐的策略吗?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)