Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function getBaseStateFromCache(
cache: ApolloCacheWithData,
objectState: ObjectState,
mutationOptions: MutationOptions
): ConflictResolutionData {
const context = mutationOptions.context;
if (!context.conflictBase) {
// do nothing
const conflictBase = getObjectFromCache(cache, context.returnType, mutationOptions);
if (conflictBase && Object.keys(conflictBase).length !== 0) {
if (objectState.hasConflict(mutationOptions.variables, conflictBase)) {
// 🙊 Input data is conflicted with the latest server projection
throw new LocalConflictError(conflictBase, mutationOptions.variables);
}
return conflictBase;
}
}
}