apollo-cache-invalidation
apollo-cache-invalidation copied to clipboard
Throws exception when clearing a cached result of `null`
When one of my patterns matches a path in the store that has a value of null, I get this error:
apollo.umd.js:1508 TypeError: Cannot convert undefined or null to object
at Function.keys (<anonymous>)
at isReference (webpack:///./~/apollo-cache-invalidation/lib/index.js?:42:17)
at Object.findMatches (webpack:///./~/apollo-cache-invalidation/lib/index.js?:64:9)
at Object.eval (webpack:///./~/traverse/index.js?:59:22)
at walker (webpack:///./~/traverse/index.js?:190:22)
at eval (webpack:///./~/traverse/index.js?:208:29)
at Array.forEach (native)
at forEach (webpack:///./~/traverse/index.js?:298:31)
at walker (webpack:///./~/traverse/index.js?:203:13)
at eval (webpack:///./~/traverse/index.js?:208:29)
Looks like the problem is that findMatches assumes that this.node is an object and not null.
Could you work on a pull-request?
Unfortunately I don't have a lot of time right now and I was able to find a workaround that was actually probably a better choice in my particular scenario (instead of invalidating that particular part of the cache, I called writeQuery to populate it since I had the data that should go there available) Sorry :(
Thanks for pointing out the bug ;)