@nerdwallet/apollo-cache-policies
Advanced tools
Comparing version 3.1.0 to 3.1.1
@@ -0,1 +1,5 @@ | ||
3.1.1 (Dan Reynolds) | ||
Fix duplicate collection references bug. | ||
3.1.0 (Dan Reynolds) | ||
@@ -2,0 +6,0 @@ |
@@ -233,6 +233,20 @@ "use strict"; | ||
data: (existing, { canRead }) => { | ||
const existingReferences = existing; | ||
let hasDuplicateRef = false; | ||
const existingReferencesById = existingReferences.reduce((acc, ref) => { | ||
const { __ref } = ref; | ||
if (!hasDuplicateRef && acc[__ref]) { | ||
hasDuplicateRef = true; | ||
} | ||
acc[__ref] = ref; | ||
return acc; | ||
}, {}); | ||
const newReferences = Object.values(updatedReferences).filter((ref) => !existingReferencesById[ref.__ref] && canRead(ref)); | ||
if (!hasDuplicateRef && newReferences.length === 0) { | ||
return existing; | ||
} | ||
return [ | ||
...existing, | ||
...Object.values(updatedReferences), | ||
].filter(canRead); | ||
...Object.values(existingReferencesById), | ||
...newReferences, | ||
]; | ||
} | ||
@@ -239,0 +253,0 @@ } |
{ | ||
"name": "@nerdwallet/apollo-cache-policies", | ||
"version": "3.1.0", | ||
"version": "3.1.1", | ||
"description": "An extension to the InMemoryCache from Apollo that adds additional cache policies.", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
335830
2494