【发布时间】:2020-07-17 15:06:41
【问题描述】:
我在意外的位置看到了一些类验证器错误。我希望有一种更方便的格式来处理错误,但也许我不知道一些用于处理扩展字段中对象的 graphQL 技巧......
在运行 NestJS sample/23-graphql-code-first 时,我在 GraphQL 操场上看到以下内容:
有输入:
addRecipe(newRecipeData: {
description: "too short"
title: "this field should fail for being too long"
ingredients: ["normal"]
}) {
title
}
}
我回来了:
"errors": [
{
"message": "Bad Request Exception",
"locations": [
{
"line": 2,
"column": 3
}
],
"path": [
"addRecipe"
],
"extensions": {
"code": "INTERNAL_SERVER_ERROR",
"exception": {
"response": {
"statusCode": 400,
"message": [
"title must be shorter than or equal to 30 characters",
"description must be longer than or equal to 30 characters"
],
"error": "Bad Request"
},
"status": 400,
"message": "Bad Request Exception",
"stacktrace": [
"Error: Bad Request Exception",
" at ValidationPipe.exceptionFactory nest/sample/23-graphql-code-first/node_modules/@nestjs/common/pipes/validation.pipe.js:78:20)",
...
]
}
}
}
],
"data": null
}
这些错误嵌套很深,“Bad Request Exception”没那么有用。这是否按预期工作?
【问题讨论】:
-
nestjs 哪个版本?
-
@raven 版本 7.0.7
-
你能在 GitHub 上为此创建一个问题吗?我认为这是一个错误。
标签: nestjs