question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

new InMemoryCache throws an error

See original GitHub issue

Trying 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:closed
  • Created 4 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

6reactions
dhavaljardoshcommented, Dec 2, 2020

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.

Error

0reactions
jmarcacommented, May 20, 2020

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.

Read more comments on GitHub >

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

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found