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)
})
I got the same problem. My app always worked until I reinstalled everything today. Running
"apollo-boost": "^0.1.6",
"apollo-cache-redux": "^0.1.0",
"apollo-client": "^2.3.1",
"apollo-link-redux": "^0.2.1",
"expo": "^30.0.0",
"graphql": "^0.13.2",
"graphql-tag": "^2.9.2",
"react": "16.3.1",
"react-apollo": "^2.1.4",
"react-native": "https://github.com/expo/react-native/archive/sdk-30.0.0.tar.gz"
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 [email protected]
I solved it by using inmemorycache
`const cache2 = new InMemoryCache();``
instead of my Redux Cache
const cache = new ReduxCache({ store });
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 [email protected]
I have also locked the version to [email protected]
Possible that the error was caused by this commit?
https://github.com/apollographql/apollo-client/commit/a668a6f4af096137b31a0ec42ed5cefacbd27e78#diff-fe50f840c179cc1955e7a0dac67e2097
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 +
I have also locked the version to [email protected]
Possible that the error was caused by this commit?
a668a6f#diff-fe50f840c179cc1955e7a0dac67e2097
I don't know, but nice find @soniachan!
I can confirm the problem exists since 1.0.24
. When using yarn, going with selective dependency resolution works fine. Thanks @soniachan.
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.
we are also experiencing this issue. we recently nuked our node_modules and re-installed our packages. some packages ended up being resolved differently than they used to. this eventually introduced this current issue. with all the apollo + graphql packages we are using, and all the internal dependencies that they bring, we really found ourselves in a pickle. We tried a bunch of tricks to no avail, including re-evaluating all of our dependencies, and yarn resolutions. We'd be very grateful for anyone who'd offer some help here. FYI, here are the package versions we're using:
apollo-cache-inmemory": "1.1.11",
"apollo-client": "2.4.6",
"apollo-link": "1.2.3",
"apollo-link-http": "1.5.5",
"apollo-utilities": "1.0.22",
"react-apollo": "2.3.1",
"graphql": "0.13.1",
"graphql-anywhere": "4.1.7",
"graphql-tag": "2.10.0",
@sacummings91 tip helped
yarn upgrade [email protected]
did the trick for me
@ sacummings91 tip ajudou
yarn upgrade [email protected]
fez o truque para mim
My problem was solved, thank you.
Moving from 1.2 to 1.3 solved the issue. For those who still use npm: npm update apollo-cache-inmemory
I am also suddenly seeing this problem with [email protected]. I cannot easily upgrade to 1.3.0+ because doing so breaks rendering of updates after mutations in my application. But I suddenly can't run any unit tests that use MockedProvider
or I see this error:
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.
98 | mock3.result.data.someData = data //mock2.result.data.someData
99 |
> 100 | const parent = mount(
| ^
101 | <MockedProvider mocks={[mock1, mock2, mock3]} addTypename={false} >
102 | <MyComponent userCanEdit={true}/>
103 | </MockedProvider>
at assertIdValue (node_modules/apollo-cache-inmemory/src/readFromStore.ts:218:11)
at readStoreResolver (node_modules/apollo-cache-inmemory/src/readFromStore.ts:69:3)
at executeField (node_modules/graphql-anywhere/lib/bundle.esm.js:71:18)
at node_modules/graphql-anywhere/lib/bundle.esm.js:28:31
at Array.forEach (<anonymous>)
at executeSelectionSet (node_modules/graphql-anywhere/lib/bundle.esm.js:23:29)
at graphql (node_modules/graphql-anywhere/lib/bundle.esm.js:18:12)
at diffQueryAgainstStore (node_modules/apollo-cache-inmemory/src/readFromStore.ts:198:18)
at InMemoryCache.Object.<anonymous>.InMemoryCache.diff (node_modules/apollo-cache-inmemory/src/inMemoryCache.ts:119:12)
at QueryManager.Object.<anonymous>.QueryManager.fetchQuery (node_modules/src/core/QueryManager.ts:340:13)
at QueryManager.Object.<anonymous>.QueryManager.startQuery (node_modules/src/core/QueryManager.ts:891:10)
at ObservableQuery.Object.<anonymous>.ObservableQuery.setUpQuery (node_modules/src/core/ObservableQuery.ts:598:23)
at ObservableQuery.Object.<anonymous>.ObservableQuery.onSubscribe (node_modules/src/core/ObservableQuery.ts:557:43)
at node_modules/src/core/ObservableQuery.ts:92:12
at new Subscription (node_modules/zen-observable/lib/Observable.js:183:34)
at ObservableQuery.subscribe (node_modules/zen-observable/lib/Observable.js:262:14)
at Query._this.startQuerySubscription (node_modules/react-apollo/react-apollo.umd.js:290:65)
at Query.Object.<anonymous>.Query.componentDidMount (node_modules/react-apollo/react-apollo.umd.js:377:18)
at CallbackQueue.notifyAll (../../node_modules/react-dom/lib/CallbackQueue.js:74:22)
at ReactReconcileTransaction.close (../../node_modules/react-dom/lib/ReactReconcileTransaction.js:78:26)
at ReactReconcileTransaction.closeAll (../../node_modules/react-dom/lib/Transaction.js:207:25)
at ReactReconcileTransaction.perform (../../node_modules/react-dom/lib/Transaction.js:154:16)
at batchedMountComponentIntoNode (../../node_modules/react-dom/lib/ReactMount.js:124:15)
at ReactDefaultBatchingStrategyTransaction.perform (../../node_modules/react-dom/lib/Transaction.js:141:20)
at Object.batchedUpdates (../../node_modules/react-dom/lib/ReactDefaultBatchingStrategy.js:60:26)
at Object.batchedUpdates (../../node_modules/react-dom/lib/ReactUpdates.js:95:27)
at Object._renderNewRootComponent (../../node_modules/react-dom/lib/ReactMount.js:317:18)
at Object._renderSubtreeIntoContainer (../../node_modules/react-dom/lib/ReactMount.js:399:32)
at Object.render (../../node_modules/react-dom/lib/ReactMount.js:420:23)
at Object.render (../../node_modules/enzyme-adapter-react-15/build/ReactFifteenAdapter.js:190:50)
at new ReactWrapper (../../node_modules/enzyme/build/ReactWrapper.js:134:16)
at mount (../../node_modules/enzyme/build/mount.js:21:10)
I'm going to close this issue since it hasn't received a lot of traction recently and seems to be fixed by a new version. It sounds like upgrading to the latest release is the best way to resolve this, though of course the feasibility of doing that upgrade is project specific.
If this is still a problem, we welcome anyone who is experiencing the problem (or anyone who comes across this issue and is able to assist) to build a reproduction of the problem into a runnable CodeSandbox reproduction](https://codesandbox.io/), using the latest versions of the appropriate packages, and sharing the link to that reproduction in this issue.
I'm happy to re-open if this is still occurring and someone can provide a reproduction, though a new issue which references this issue is probably best. Thanks!
I have fixed this bug in apollo-cache-redux
. Since apollo-cache-redux
is deprecated, you can now use @codejamninja/apollo-cache-redux
.
npm install --save @codejamninja/apollo-cache-redux
import { ReduxCache, apolloReducer } from '@codejamninja/apollo-cache-redux';
https://github.com/codejamninja/apollo-cache-redux
https://www.npmjs.com/package/@codejamninja/apollo-cache-redux
This fixes the following issues
https://github.com/rportugal/apollo-cache-redux/issues/27
https://github.com/rportugal/apollo-cache-redux/issues/35
Most helpful comment
@sacummings91 tip helped
yarn upgrade [email protected]
did the trick for me