apollo-client: Sudden error: Encountered a sub-selection on the query, but the store doesn't have \ an object reference
The following error was hit suddenly since around 10 days ago…
A simple mutation and refetchQuery was made
this.apollo.mutate({ mutation: GraphQL.Mutation.updateAccount, refetchQueries: [{ query: GraphQL.Query.accountQuery, variables: { filter: this.account.id, } }], variables: { accountId: this.account.id } })
Encountered a sub-selection on the query, but the store doesn’t have
an object reference. This should never happen during normal use unless you have custom code
that is directly manipulating the store; please file an issue.
Does anyone have any idea to fix this error?
My inmemorycache was set with
cache: new InMemoryCache({ dataIdFromObject: object => object['id'] || defaultDataIdFromObject(object) })
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 8
- Comments: 15 (2 by maintainers)
@sacummings91 tip helped
yarn upgrade apollo-cache-inmemory@1.3.0
did the trick for meI saw this problem today after nuking
node_modules
and reinstalling. Not sure yet why it’s happening, but I seem to have gotten rid of the problem by running:Hey guys, ran into the same bug over here. Seemingly out of nowhere. Based on @rajit and @soniachan comments we experimented with adding
apollo-utilities
1.0.22
to our dependencies. Which also worked for us. But ultimately our fix involved updatingapollo-cache-inmemory
andapollo-client
to latest versions. We were on1.2.6
and2.3.7
respectively.My code was already using InMemoryCache, however the error persists when using apollo-utilities with version 1.0.24 +
Moving from 1.2 to 1.3 solved the issue. For those who still use npm:
npm update apollo-cache-inmemory
I have also locked the version to apollo-utilities@1.0.23 Possible that the error was caused by this commit? https://github.com/apollographql/apollo-client/commit/a668a6f4af096137b31a0ec42ed5cefacbd27e78#diff-fe50f840c179cc1955e7a0dac67e2097
My problem was solved, thank you.
I can confirm the problem exists since
1.0.24
. When using yarn, going with selective dependency resolution works fine. Thanks @soniachan.I don’t know, but nice find @soniachan!