From 2fd7829b882442458df84701008661b5b061c6bb Mon Sep 17 00:00:00 2001 From: Chi Vinh Le Date: Fri, 13 Oct 2017 17:33:59 +0700 Subject: [PATCH] Prevent calling updators when there is an error --- client/coral-framework/hocs/withMutation.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/client/coral-framework/hocs/withMutation.js b/client/coral-framework/hocs/withMutation.js index f16809322..cb6bc3789 100644 --- a/client/coral-framework/hocs/withMutation.js +++ b/client/coral-framework/hocs/withMutation.js @@ -108,7 +108,7 @@ export default (document, config = {}) => hoistStatics((WrappedComponent) => { res[key] = (prev, result) => { if (getResponseErrors(result.mutationResult)) { - // Do not run updates when we have mutation errors. + // Do not run updates when we have mutation errors. return prev; } return map[key](prev, result) || prev; @@ -116,6 +116,11 @@ export default (document, config = {}) => hoistStatics((WrappedComponent) => { } else { const existing = res[key]; res[key] = (prev, result) => { + if (getResponseErrors(result.mutationResult)) { + + // Do not run updates when we have mutation errors. + return prev; + } const next = existing(prev, result); return map[key](next, result) || next; };