File tree Expand file tree Collapse file tree 2 files changed +8
-3
lines changed Expand file tree Collapse file tree 2 files changed +8
-3
lines changed Original file line number Diff line number Diff line change 22 * The magic 'Notification' prefix comes from inspecting the apollo cache.
33 * I think it comes from the __typename when apollo caches an object (by default)
44 */
5- export const NOTIFICATION_CACHE_PREFIX = "Notification" ;
5+ export const NotificationType = "Notification" ;
6+
Original file line number Diff line number Diff line change 11import { InMemoryCache , type InMemoryCacheConfig } from "@apollo/client/core" ;
22import { mergeAndDedup } from "./merge" ;
3- import { NOTIFICATION_CACHE_PREFIX } from "./prefixes " ;
3+ import { NotificationType } from "../../composables/gql/typename " ;
44
55/**------------------------------------------------------------------------
66 * ! Understanding Cache Type Policies
@@ -90,7 +90,11 @@ const defaultCacheConfig: InMemoryCacheConfig = {
9090 */
9191 merge ( _ , incoming , { cache, args } ) {
9292 if ( args ?. id ) {
93- cache . evict ( { id : `${ NOTIFICATION_CACHE_PREFIX } :${ args . id } ` } ) ;
93+ const id = cache . identify ( {
94+ id : args . id ,
95+ __typename : NotificationType ,
96+ } ) ;
97+ cache . evict ( { id } ) ;
9498 }
9599 // Removes references to evicted notification, preventing dangling references
96100 cache . gc ( ) ;
You can’t perform that action at this time.
0 commit comments