Skip to content

[Request]: Proper way to override validation error messages through Graphql Plugin #2777

@rahimlis

Description

@rahimlis

Summary

I need custom validation error messages for the backend that would look like
content-type.validation.field.error-type. But I found it is very cumbersome to implement without doing a lot of additional things like overriding lifecycles, adding graphql middlewares etc.

{ "errors": [ { "message": "This attribute must be unique", "path": [ "createMarketingLead" ], "extensions": { "code": "BAD_USER_INPUT", "error": { "name": "ValidationError", "message": "This attribute must be unique", "details": { "errors": [ { "path": [ "email" ], "message": "This attribute must be unique", "name": "ValidationError", "value": "aa@aas.aa" } ] } } } } ], "data": { "createMarketingLead": null } }

Instead of "This attribute must be unique", it could be a marketing-lead.validation.email.required, which in turn allows for end users to hold the i18n strings.

Why is it needed?

The messages are currently in unorganized format. A central coding mechanism would be great addition to the framework and organize error handling structurally.

Suggested solution(s)

No response

Related issue(s)/PR(s)

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions