Open G0maa opened 1 month ago
I just noticed I forgot to add:
app.useGlobalPipes(new ValidationPipe());
In main.ts
.
EDIT: GraphQL helloWorld
query, i.e. class-validator
without i18n now works correctly I think:
{
"errors": [
{
"message": "Bad Request Exception",
"locations": [
{
"line": 2,
"column": 3
}
],
"path": [
"helloWorld"
],
"extensions": {
"code": "BAD_REQUEST",
"stacktrace": [
"BadRequestException: Bad Request Exception",
" at ValidationPipe.exceptionFactory (/home/gomaa-zorin/Github/GE-Techs/i18n-graphql/node_modules/@nestjs/common/pipes/validation.pipe.js:101:20)",
" at ValidationPipe.transform (/home/gomaa-zorin/Github/GE-Techs/i18n-graphql/node_modules/@nestjs/common/pipes/validation.pipe.js:74:30)",
" at process.processTicksAndRejections (node:internal/process/task_queues:95:5)",
" at async /home/gomaa-zorin/Github/GE-Techs/i18n-graphql/node_modules/@nestjs/core/pipes/pipes-consumer.js:15:25",
" at async resolveParamValue (/home/gomaa-zorin/Github/GE-Techs/i18n-graphql/node_modules/@nestjs/core/helpers/external-context-creator.js:136:31)",
" at async Promise.all (index 0)",
" at async pipesFn (/home/gomaa-zorin/Github/GE-Techs/i18n-graphql/node_modules/@nestjs/core/helpers/external-context-creator.js:138:13)",
" at async /home/gomaa-zorin/Github/GE-Techs/i18n-graphql/node_modules/@nestjs/core/helpers/external-context-creator.js:66:17"
],
"originalError": {
"message": [
"page must not be less than 1"
],
"error": "Bad Request",
"statusCode": 400
}
}
}
],
"data": null
}
And this is the result of helloWorldI18n
:
{
"errors": [
{
"message": "Bad Request Exception",
"locations": [
{
"line": 2,
"column": 3
}
],
"path": [
"helloWorldI18n"
],
"extensions": {
"code": "BAD_REQUEST",
"stacktrace": [
"BadRequestException: Bad Request Exception",
" at ValidationPipe.exceptionFactory (/home/gomaa-zorin/Github/GE-Techs/i18n-graphql/node_modules/@nestjs/common/pipes/validation.pipe.js:101:20)",
" at ValidationPipe.transform (/home/gomaa-zorin/Github/GE-Techs/i18n-graphql/node_modules/@nestjs/common/pipes/validation.pipe.js:74:30)",
" at process.processTicksAndRejections (node:internal/process/task_queues:95:5)",
" at async /home/gomaa-zorin/Github/GE-Techs/i18n-graphql/node_modules/@nestjs/core/pipes/pipes-consumer.js:15:25",
" at async resolveParamValue (/home/gomaa-zorin/Github/GE-Techs/i18n-graphql/node_modules/@nestjs/core/helpers/external-context-creator.js:136:31)",
" at async Promise.all (index 0)",
" at async pipesFn (/home/gomaa-zorin/Github/GE-Techs/i18n-graphql/node_modules/@nestjs/core/helpers/external-context-creator.js:138:13)",
" at async /home/gomaa-zorin/Github/GE-Techs/i18n-graphql/node_modules/@nestjs/core/helpers/external-context-creator.js:66:17"
],
"originalError": {
"message": [
"validation.Generic|{\"value\":-1,\"constraints\":[1]}"
],
"error": "Bad Request",
"statusCode": 400
}
}
}
],
"data": null
}
Hence the "validation.Generic|{\"value\":-1,\"constraints\":[1]}"
.
I got this error in some other project (similar configuration, not identical), dunno if it's related or not:
{
"errors": [
{
"message": "Cannot read properties of undefined (reading 'service')",
"locations": [
{
"line": 2,
"column": 3
}
],
"path": [
"shoppingLists"
],
"extensions": {
"code": "INTERNAL_SERVER_ERROR",
"stacktrace": [
"TypeError: Cannot read properties of undefined (reading 'service')",
" at I18nValidationExceptionFilter.catch (/home/gomaa-zorin/Github/GE-Techs/rasheed-backend/node_modules/nestjs-i18n/src/filters/i18n-validation-exception.filter.ts:31:66)",
" at ExternalExceptionsHandler.invokeCustomFilters (/home/gomaa-zorin/Github/GE-Techs/rasheed-backend/node_modules/@nestjs/core/exceptions/external-exceptions-handler.js:31:32)",
" at ExternalExceptionsHandler.next (/home/gomaa-zorin/Github/GE-Techs/rasheed-backend/node_modules/@nestjs/core/exceptions/external-exceptions-handler.js:14:29)",
" at Object.shoppingLists (/home/gomaa-zorin/Github/GE-Techs/rasheed-backend/node_modules/@nestjs/core/helpers/external-proxy.js:14:42)",
" at process.processTicksAndRejections (node:internal/process/task_queues:95:5)"
]
}
}
],
"data": null
}
Describe the bug
Hello, thanks for the package! :rose:
As in the provided code sample, RESTful requests work correctly (when validation fails or passes), GraphQL requests fail when validation fails, resulting in this error:
Any help is appreciated!
Reproduction
https://github.com/G0maa/i18n-graphql
System Info
Used Package Manager
npm
Validations