小编Cal*_*gal的帖子

为什么 NestJS GraphQL 验证错误没有放置在错误消息字段中?

我在意外的位置看到了一些类验证器错误。我希望有一种更方便的格式来处理错误,但也许我不知道一些用于处理扩展字段中对象的 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
  }
}
Run Code Online (Sandbox Code Playgroud)

我回来了:

  "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 …
Run Code Online (Sandbox Code Playgroud)

nestjs

5
推荐指数
3
解决办法
3226
查看次数

标签 统计

nestjs ×1