Kristof Dombi
01/28/2018, 8:35 PM<http://howtographql.com/react-apollo|howtographql.com/react-apollo>
tutorial and I got blocked by an error at the More mutations and updating the store state
section.
Can someone help me with this?
_updateCacheAfterVote = (store, createVote, linkId) => {
// 1
const data = store.readQuery({ query: FEED_QUERY })
// 2
const votedLink = data.feed.links.find(link => link.id === linkId)
votedLink.votes = createVote.link.votes
// 3
store.writeQuery({ query: FEED_QUERY, data })
}
at store.readQuery({ query: FEED_QUERY })
i get the following error:
index.js:2178 Error: Can't find field feed({"first":100,"skip":0,"orderBy":null}) on object (ROOT_QUERY) {
"feed({\"first\":null,\"skip\":null,\"orderBy\":null})": {
"type": "id",
"id": "$ROOT_QUERY.feed({\"first\":null,\"skip\":null,\"orderBy\":null})",
"generated": true
}
}.
at readStoreResolver (readFromStore.js:39)
at executeField (graphql.js:70)
at graphql.js:27
at Array.forEach (anonymous)
at executeSelectionSet (graphql.js:22)
at graphql (graphql.js:17)
at diffQueryAgainstStore (readFromStore.js:71)
at readQueryFromStore (readFromStore.js:14)
at InMemoryCache../node_modules/apollo-cache-inmemory/lib/inMemoryCache.js.InMemoryCache.read (inMemoryCache.js:75)
at InMemoryCache../node_modules/apollo-cache-inmemory/lib/inMemoryCache.js.InMemoryCache.readQuery (inMemoryCache.js:165)
at Object.LinkList._this._updateCacheAfterVote [as updateStoreAfterVote] (LinkList.js:37)
at update (Link.js:44)
at store.js:113
at tryFunctionOrLogError (errorHandling.js:3)
at store.js:113
at InMemoryCache../node_modules/apollo-cache-inmemory/lib/inMemoryCache.js.InMemoryCache.performTransaction (inMemoryCache.js:135)
at DataStore../node_modules/apollo-client/data/store.js.DataStore.markMutationResult (store.js:112)
at Object.next (QueryManager.js:95)
at SubscriptionObserver.next (zen-observable.js:154)
at httpLink.js:140
at anonymous
I’ve been around the web to find a solution for this problem, but none of them helped me. 😞
Thanks in advance for your help!QuCode
01/28/2018, 8:51 PMKristof Dombi
01/28/2018, 8:53 PMQuCode
01/28/2018, 8:53 PMKristof Dombi
01/28/2018, 9:01 PMnikolasburk