Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
dataIdFromObject(object: any) {
// WORKAROUND: Because of Apollo's aggressive caching, often the current User will be overwritten with results
// from other queries. The server side often strips fields based on how they're accessed (the "ScopeRole" logic),
// which means these query paths will often return different data with the same IDs:
// currentUser -> primaryGroup (always present)
// dataset -> submitter -> primaryGroup (null unless admin)
// To protect against this, don't allow Users (and possibly other types in the future) to have a dataId,
// so that InMemoryCache cannot share data between different queries.
if (nonNormalizableTypes.includes(object.__typename)) {
return null
} else {
return defaultDataIdFromObject(object)
}
},
})