Skip to content

Commit

Permalink
Merge pull request #3130 from ONSdigital/EAR-2208-create-view-eq-page
Browse files Browse the repository at this point in the history
EAR-2208 - Create View in EQ page
  • Loading branch information
sudeepkunhis authored Nov 25, 2024
2 parents ec6ffa9 + b0c23ab commit 773a1ce
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
5 changes: 5 additions & 0 deletions eq-author-api/schema/resolvers/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ const {
getAnswerByOptionId,
setDataVersion,
authorisedRequest,
returnAllValidationErrors,
} = require("./utils");

const createAnswer = require("../../src/businessLogic/createAnswer");
Expand Down Expand Up @@ -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;
},
Expand Down
19 changes: 19 additions & 0 deletions eq-author-api/schema/resolvers/utils/validation.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
14 changes: 14 additions & 0 deletions eq-author-api/schema/typeDefs.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ type Questionnaire {
locked: Boolean
publishHistory: [PublishHistoryEvent]
validationErrorInfo: ValidationErrorInfo
allValidationErrorInfo: AllValidationErrorInfo
submission: Submission
supplementaryData: SupplementaryData
}
Expand Down Expand Up @@ -487,12 +488,25 @@ type ValidationError {
errorCode: String!
}
type AllValidationError {
id: String!
type: String!
field: String!
errorCode: String!
pageId: String
}
type ValidationErrorInfo {
id: ID!
errors: [ValidationError!]!
totalCount: Int!
}
type AllValidationErrorInfo {
id: ID!
errors: [AllValidationError!]!
totalCount: Int!
}
union ValidationType = NumberValidation | DateValidation | DateRangeValidation
Expand Down

0 comments on commit 773a1ce

Please sign in to comment.