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)

Commits related to this issue

Most upvoted comments

@sacummings91 tip helped

yarn upgrade apollo-cache-inmemory@1.3.0 did the trick for me

I 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:

npm install --no-save apollo-utilities@1.0.22

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 updating apollo-cache-inmemory and apollo-client to latest versions. We were on 1.2.6 and 2.3.7 respectively.

I solved it by using inmemorycache `const cache2 = new InMemoryCache();``

instead of my Redux Cache

const cache = new ReduxCache({ store });

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 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:

npm install --no-save apollo-utilities@1.0.22

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

@ sacummings91 tip ajudou

yarn upgrade apollo-cache-inmemory@1.3.0 fez o truque para mim

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 have also locked the version to apollo-utilities@1.0.23 Possible that the error was caused by this commit? a668a6f#diff-fe50f840c179cc1955e7a0dac67e2097

I don’t know, but nice find @soniachan!