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}`,
  })