Search code examples
apolloreact-apollo

Apollo duplicates first result to every node in array of edges


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


Solution

  • Put this in your App.js

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