jsaelhof / movie-picker

Next.js test app. Keeps a list of movies to watch across various streaming services and randomly picks one.
https://moviedecider4000.vercel.app
2 stars 0 forks source link

Try to use "toReference" in second argument to update cache instead of building it with my own util #66

Closed jsaelhof closed 2 years ago

jsaelhof commented 2 years ago

Reference: https://community.apollographql.com/t/how-exactly-do-you-update-an-array-in-the-cache-after-a-mutation/315

Look at this:

movies(existingItems = [], { toReference }) ( [...existingItems, toReference(addItem)] )

Instead of this:

export const cacheInsert = (cacheList, id) => cacheList.concat({ __ref: Movie:${id} });