ApolloError: this.cache.batch is not a function
See original GitHub issueHi.
trying some auth mutation over the new released Apollo/client 3.4.1 and i have this error :
ApolloError: this.cache.batch is not a function
at new ApolloError (/var/task/node_modules/@apollo/client/errors/errors.cjs.js:35:28)
at Object.error (/var/task/node_modules/@apollo/client/core/core.cjs.js:1073:90)
at notifySubscription (/var/task/node_modules/zen-observable/lib/Observable.js:140:18)
at onNotify (/var/task/node_modules/zen-observable/lib/Observable.js:179:3)
at SubscriptionObserver.error (/var/task/node_modules/zen-observable/lib/Observable.js:240:7)
at /var/task/node_modules/@apollo/client/utilities/utilities.cjs.js:1015:40
at processTicksAndRejections (internal/process/task_queues.js:95:5) {
graphQLErrors: [],
clientErrors: [],
networkError: TypeError: this.cache.batch is not a function
at QueryManager.refetchQueries (/var/task/node_modules/@apollo/client/core/core.cjs.js:1601:24)
at QueryManager.markMutationResult (/var/task/node_modules/@apollo/client/core/core.cjs.js:1136:18)
at /var/task/node_modules/@apollo/client/core/core.cjs.js:1043:49
at both (/var/task/node_modules/@apollo/client/utilities/utilities.cjs.js:1004:53)
at /var/task/node_modules/@apollo/client/utilities/utilities.cjs.js:997:72
at new Promise (<anonymous>)
at Object.then (/var/task/node_modules/@apollo/client/utilities/utilities.cjs.js:997:24)
at Object.next (/var/task/node_modules/@apollo/client/utilities/utilities.cjs.js:1005:49)
at notifySubscription (/var/task/node_modules/zen-observable/lib/Observable.js:135:18)
at onNotify (/var/task/node_modules/zen-observable/lib/Observable.js:179:3),
extraInfo: undefined
}
Issue Analytics
- State:
- Created 2 years ago
- Reactions:3
- Comments:11 (3 by maintainers)
Top Results From Across the Web
ApolloError: this.cache.batch is not a function - Stack Overflow
This issue is related to the deprecated cacher class. If you are using some cacher class just make sure it's up to date....
Read more >Advanced topics on caching in Apollo Client
This article describes special cases and considerations when using the Apollo Client cache. Bypassing the cache. Sometimes you shouldn't use the cache for...
Read more >this.cache.batch is not a function - Zenn
trying some auth mutation over Apollo/client 3.4.1 and i have this error : ApolloError: this.cache. stackoverflow.com favicon image ...
Read more >apollo-cache-inmemory - Awesome JS
IMPORTANT Version 3.7.3 is not installable due to an issue with our ... Make cache.batch return the result of calling the options.update function....
Read more >Customizing the behavior of cached fields - Client (React)
The following read function assigns a default value of UNKNOWN NAME to the name field of a Person type, if the actual value...
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
@carelulu-igor Thank you for including your imports, especially the import of
InMemoryCache
.The reason this code is not using the latest implementation of
InMemoryCache
is that it’s still importingInMemoryCache
from the AC2apollo-cache-inmemory
npm package (last published more than a year ago!). You can/should importInMemoryCache
from@apollo/client
instead now. The older package still exists for folks also using the olderapollo-client
package, but you definitely should not be mixing@apollo/client
andapollo-cache-inmemory
together.The good news: you’re about to experience a ton of improvements to
InMemoryCache
all at once!The realistic news: some of those changes will be breaking. For example, the
IntrospectionFragmentMatcher
no longer exists. Fortunately, the new way of providingpossibleTypes
is much simpler:While you’re at it, I would also suggest you stop using
apollo-link-http
and importcreateHttpLink
this way instead:These won’t be the only changes you’ll have to contend with as you update, but I hope you’ll find the
InMemoryCache
-related parts of the AC3 migration guide useful.@mfurniss Does this explanation of @carelulu-igor’s problem explain what’s up in your case? I can’t really tell if they’re the same problem from the code you provided above.
I have the same error on our dev server with both 3.3.21 as 3.4.1. Locally everything runs fine but on the dev server when I execute the mutation, it goes straight after in the catch function (even though I get a 200 response with correct data) and outputs ‘this.cache.batch is not a function’. I’m using default InMemoryCache which I cleared too.