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.

cache.modify() not a function

See original GitHub issue

Hello,

I have a problem with cache.modify() when trying to update the cache in a resolver with the v.3.0 beta @apollo/client version.

The chrome browser tells me that modify() is not a function: cache.identify is working. image

Here is my code : `export const resolvers: any = {

Mutation: { updateApplicationProofUrl: (__:any, {input}:any, {cache, getCacheKey}:any) => { const {jobId, signedGetUrl} = input const id = cache.identify({ __typename: ‘Job’, id: jobId }) console.log(‘id’, id) cache.modify(id, {applicationProofUrl: signedGetUrl}) } }, }` Note : cache.identify() is working.

My cache is configured with this // Graphql default state const cache = new InMemoryCache(); const link = new HttpLink({ uri: "http://localhost:5001" }) // GraphqlClient const client = new ApolloClient<NormalizedCacheObject>({ link, cache, typeDefs, resolvers, connectToDevTools: true })

Do you have an idea of the problem ?

It’s my first ever issue posting on any library so if it misses some info, don’t hesitate to tell me.

Thank you for your help !

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:13 (2 by maintainers)

github_iconTop GitHub Comments

23reactions
larsblumbergcommented, Jul 20, 2020

Please note that https://www.apollographql.com/docs/react/data/mutations/ still refers to cache.modify in its examples

5reactions
vonkanehoffencommented, Nov 23, 2020

Aye I’m seeing this in 3.2.7. I’m reasonably new to Apollo and while lots of the docs are great, I’ just so confused about how cache updates are meant to be done without refetchQueries. 🤯

Read more comments on GitHub >

github_iconTop Results From Across the Web

Apollo Client: cache.modify does not work? - Stack Overflow
I reproduced a simple example here. I first initialized my cache with the data - const writeInitialData = () => { cache.writeQuery({ query:...
Read more >
Reading and writing data to the cache - Apollo GraphQL Docs
Directly modifying cached fields, cache.modify, Manipulate cached data without using GraphQL ... It does not attempt to fetch data from your GraphQL server....
Read more >
GraphQL Mutations and Caching using Apollo Client
Caching with Update Function. But there are times when simply including the modified objects in the mutation response is not sufficient to update...
Read more >
Build: Updating your cache with Apollo Client - YouTube
Janessa and Trevor take us through updating the cache with Apollo Client in this instalment of ... Read more about the update function...
Read more >
Reading and writing data to the cache - Client (React)
readQuery and readFragment; writeQuery and writeFragment; cache.modify (a method ... Unlike with readQuery , calls to readFragment do not need to conform to ......
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