new InMemoryCache throws an error
See original GitHub issueTrying to create a new InMemoryCache
throws an error. I am trying this in React Native, not web.
Intended outcome:
A new InMemoryCache
Actual outcome:
TypeError: optimism.dep is not a function
TypeError: optimism.dep is not a function
at new Root (http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:103974:35)
at new InMemoryCache (http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:104690:20)
at App.componentDidMount$ (http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:98694:25)
at tryCatch (http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:29753:19)
at Generator.invoke [as _invoke] (http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:29928:24)
at Generator.prototype.<computed> [as next] (http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:29796:23)
at tryCatch (http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:29753:19)
at invoke (http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:29829:22)
at http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:29859:13
at tryCallTwo (http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:6091:7)
How to reproduce the issue:
import {InMemoryCache} from '@apollo/client'
const cache = new InMemoryCache()
Versions
System: OS: macOS 10.15.1 Binaries: Node: 13.1.0 - /usr/local/bin/node npm: 6.13.1 - /usr/local/bin/npm npmPackages: @apollo/client: ^3.0.0-beta.14 => 3.0.0-beta.14 apollo-cache-persist: ^0.1.1 => 0.1.1
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (1 by maintainers)
Top Results From Across the Web
Configuring the cache - Apollo GraphQL Docs
InMemoryCache throws an error if it encounters an inconsistency in the presence or absence of this field for a particular type.
Read more >net core InMemoryCache is throwing error - Stack Overflow
I am using InMemoryCache like below. I did not configure through startup.cs. The problem here is it is throwing the following error in...
Read more >Error handling | Vue Apollo
Using GraphQL brings a new set of possible errors from the actual GraphQL ... '@vue/apollo-util' const cache = new InMemoryCache() // HTTP connection...
Read more >Modeling errors in Swift - Swift with Majid
There is an option to limit the capacity of the in-memory cache and the list of errors that a cache instance can throw....
Read more >Fix: Cache data may be lost when replacing the getAllPosts ...
In this case let's add getAllAuthors query that throws the same error when an author is deleted. const cache = new InMemoryCache({ typePolicies:...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Facing the same issue.
TypeError: optimism.dep is not a function. (In 'optimism.dep()', 'optimism.dep' is undefined)
I am migrating from
react-apollo
to@apollo/client
, have tried a lot of things but was unable to fix this issue.Fixed it.
Apparently the issue was something in the shadow-cljs compilation cache. I fixed it by changing the compiler options flag (https://shadow-cljs.github.io/docs/UsersGuide.html#_output_language_options) but reverting no options to update this issue did nothing (no crash, everything working fine)
Guessing, but most likely an older version of optimism was hanging around in the shadow-cljs compilation cache after upgrading apollo and dependencies.
Sorry for the noise.