Apollo将第一个结果复制到边缘阵列中的每个节点 [英] Apollo duplicates first result to every node in array of edges

查看:51
本文介绍了Apollo将第一个结果复制到边缘阵列中的每个节点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用react-apollo开发一个react应用 当我在浏览器的网络"选项卡中签入时,通过graphql调用数据显示了数组的所有元素不同 但是我在应用程序中得到的内容或console.log(),则数组的所有元素都与第一个元素相同. 我不知道如何解决,请帮忙

I am working on a react app with react-apollo calling data through graphql when I check in browser network tab response it shows all elements of the array different but what I get or console.log() in my app then all elements of array same as the first element. I don't know how to fix please help

推荐答案

将其放入您的App.js

Put this in your App.js

cache: new InMemoryCache({
    dataIdFromObject: o => o.id ? `${o.__typename}-${o.id}` : `${o.__typename}-${o.cursor}`,
  })

这篇关于Apollo将第一个结果复制到边缘阵列中的每个节点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆