From 019e82ee998f641af3a3f3b21b46b392f0b71e7a Mon Sep 17 00:00:00 2001 From: sudeep Date: Thu, 24 Oct 2024 11:48:42 +0100 Subject: [PATCH 1/6] all validation error type Signed-off-by: sudeep --- eq-author-api/schema/typeDefs.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/eq-author-api/schema/typeDefs.js b/eq-author-api/schema/typeDefs.js index 62ffce5eae..ce10680841 100644 --- a/eq-author-api/schema/typeDefs.js +++ b/eq-author-api/schema/typeDefs.js @@ -92,6 +92,7 @@ type Questionnaire { locked: Boolean publishHistory: [PublishHistoryEvent] validationErrorInfo: ValidationErrorInfo + allValidationErrorInfo: AllValidationErrorInfo submission: Submission supplementaryData: SupplementaryData } @@ -487,12 +488,30 @@ type ValidationError { errorCode: String! } +type AllValidationError { + id: String! + type: String! + field: String! + errorCode: String! + sectionId: String + folderId: String + pageId: String + routingRuleId: String + expressionGroupId: String + expressionId: String +} + type ValidationErrorInfo { id: ID! errors: [ValidationError!]! totalCount: Int! } +type AllValidationErrorInfo { + id: ID! + errors: [AllValidationError!]! + totalCount: Int! +} union ValidationType = NumberValidation | DateValidation | DateRangeValidation From 9207822c9c93cf95382388842467a021f70286d9 Mon Sep 17 00:00:00 2001 From: sudeep Date: Thu, 24 Oct 2024 11:49:20 +0100 Subject: [PATCH 2/6] return all validation errors method Signed-off-by: sudeep --- eq-author-api/schema/resolvers/base.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/eq-author-api/schema/resolvers/base.js b/eq-author-api/schema/resolvers/base.js index e694571a53..1f39b72d57 100644 --- a/eq-author-api/schema/resolvers/base.js +++ b/eq-author-api/schema/resolvers/base.js @@ -79,6 +79,7 @@ const { getAnswerByOptionId, setDataVersion, authorisedRequest, + returnAllValidationErrors, } = require("./utils"); const createAnswer = require("../../src/businessLogic/createAnswer"); @@ -1721,6 +1722,10 @@ const Resolvers = { }, validationErrorInfo: ({ id }, _, ctx) => returnValidationErrors(ctx, id, ({ type }) => type === "root"), + + allValidationErrorInfo: ({ id }, _, ctx) => + returnAllValidationErrors(ctx, id), + totalErrorCount: (questionnaire, args, ctx) => { return ctx.validationErrorInfo.length; }, From 639f7c27d66252fa6748efadfe89a2d5b18a4918 Mon Sep 17 00:00:00 2001 From: sudeep Date: Thu, 24 Oct 2024 11:49:44 +0100 Subject: [PATCH 3/6] new method to get all validation errors Signed-off-by: sudeep --- .../schema/resolvers/utils/validation.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/eq-author-api/schema/resolvers/utils/validation.js b/eq-author-api/schema/resolvers/utils/validation.js index 07c1b47bc7..d264658f0d 100644 --- a/eq-author-api/schema/resolvers/utils/validation.js +++ b/eq-author-api/schema/resolvers/utils/validation.js @@ -45,8 +45,27 @@ const returnValidationErrors = (ctx, id, ...conditions) => { }; }; +const returnAllValidationErrors = (ctx, id) => { + const errors = getValidationErrorInfo(ctx); + + if (!errors.length) { + return { + id, + errors: [], + totalCount: 0, + }; + } + + return { + id, + errors, + totalCount: errors.length, + }; +}; + module.exports = { getValidationById, getValidationErrorInfo, returnValidationErrors, + returnAllValidationErrors, }; From 92baa4df76b79dc09bff13e07e59cd15723828a4 Mon Sep 17 00:00:00 2001 From: sudeep Date: Thu, 24 Oct 2024 15:28:19 +0100 Subject: [PATCH 4/6] cleanup Signed-off-by: sudeep --- eq-author-api/schema/typeDefs.js | 5 ----- 1 file changed, 5 deletions(-) diff --git a/eq-author-api/schema/typeDefs.js b/eq-author-api/schema/typeDefs.js index ce10680841..928f8cea3d 100644 --- a/eq-author-api/schema/typeDefs.js +++ b/eq-author-api/schema/typeDefs.js @@ -493,12 +493,7 @@ type AllValidationError { type: String! field: String! errorCode: String! - sectionId: String - folderId: String pageId: String - routingRuleId: String - expressionGroupId: String - expressionId: String } type ValidationErrorInfo { From 383a1f1d0ef00348270d97e27bb424520238f2b7 Mon Sep 17 00:00:00 2001 From: sudeep Date: Mon, 28 Oct 2024 12:49:06 +0000 Subject: [PATCH 5/6] cleanup Signed-off-by: sudeep --- eq-author-api/schema/resolvers/base.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/eq-author-api/schema/resolvers/base.js b/eq-author-api/schema/resolvers/base.js index 1f39b72d57..19cc5fbf91 100644 --- a/eq-author-api/schema/resolvers/base.js +++ b/eq-author-api/schema/resolvers/base.js @@ -1722,10 +1722,8 @@ const Resolvers = { }, validationErrorInfo: ({ id }, _, ctx) => returnValidationErrors(ctx, id, ({ type }) => type === "root"), - allValidationErrorInfo: ({ id }, _, ctx) => returnAllValidationErrors(ctx, id), - totalErrorCount: (questionnaire, args, ctx) => { return ctx.validationErrorInfo.length; }, From 25f9c4bd306398ff63dfbbeb163e837759d2b90f Mon Sep 17 00:00:00 2001 From: sudeep Date: Mon, 4 Nov 2024 13:24:10 +0000 Subject: [PATCH 6/6] cleanup Signed-off-by: sudeep --- eq-author-api/schema/resolvers/base.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/eq-author-api/schema/resolvers/base.js b/eq-author-api/schema/resolvers/base.js index 19cc5fbf91..1f39b72d57 100644 --- a/eq-author-api/schema/resolvers/base.js +++ b/eq-author-api/schema/resolvers/base.js @@ -1722,8 +1722,10 @@ const Resolvers = { }, validationErrorInfo: ({ id }, _, ctx) => returnValidationErrors(ctx, id, ({ type }) => type === "root"), + allValidationErrorInfo: ({ id }, _, ctx) => returnAllValidationErrors(ctx, id), + totalErrorCount: (questionnaire, args, ctx) => { return ctx.validationErrorInfo.length; },