首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >错误“冲突解决程序拒绝突变”。在放大中删除时

错误“冲突解决程序拒绝突变”。在放大中删除时
EN

Stack Overflow用户
提问于 2020-12-21 23:33:35
回答 1查看 1.6K关注 0票数 2

我有一个简单的全栈放大应用程序。

这是我的模型:

代码语言:javascript
复制
type Note @model @auth(rules: [{allow: public}]) {
  id: ID!
  name: String!
  description: String
  image: String
  NoteType: NoteType @connection
}

type NoteType @model @auth(rules: [{allow: public}]) {
  id: ID!
  name: String!
}

我正在尝试删除具有以下有效负载的备注:

代码语言:javascript
复制
{
    "query": "mutation DeleteNote($input: DeleteNoteInput!, $condition: ModelNoteConditionInput) {↵  deleteNote(input: $input, condition: $condition) {↵    id↵    name↵    description↵    image↵    createdAt↵    updatedAt↵    NoteType {↵      id↵      name↵      createdAt↵      updatedAt↵    }↵  }↵}↵",
    "variables": {"input": {"id": "0c5e3ced-ffa3-4de8-9010-40b67d5bab68"}}
}

我在响应中看到的是以下json:

代码语言:javascript
复制
{
    "data": {
        "deleteNote": null
    },
    "errors": [
        {
            "path": [
                "deleteNote"
            ],
            "data": {
                "id": "0c5e3ced-ffa3-4de8-9010-40b67d5bab68",
                "name": "bb",
                "description": "bb",
                "image": "icon.png",
                "createdAt": "2020-12-21T12:00:26.743Z",
                "updatedAt": "2020-12-21T12:00:26.743Z"
            },
            "errorType": "ConflictUnhandled",
            "errorInfo": null,
            "locations": [
                {
                    "line": 1,
                    "column": 88,
                    "sourceName": null
                }
            ],
            "message": "Conflict resolver rejects mutation."
        }
    ]
}

在我尝试添加NoteType之前,代码一直在运行!这里有没有关于外键的冲突?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-04-04 22:15:35

使用ConflictResolution时,还需要包括_version字段。

代码语言:javascript
复制
{
    "query": "mutation DeleteNote($input: DeleteNoteInput!, $condition: ModelNoteConditionInput) {↵  deleteNote(input: $input, condition: $condition) {↵    id↵    name↵    description↵    image↵    createdAt↵    updatedAt↵    NoteType {↵      id↵      name↵      createdAt↵      updatedAt↵    }↵  }↵}↵",
    "variables": {"input": {"id": "0c5e3ced-ffa3-4de8-9010-40b67d5bab68", "_version": "_version value of your note object"}}
}

我还注意到,删除使用ConflictResolution的元素后,它们不会立即从数据库中删除。相反,添加了两个标志:_deleted设置为true,_ttl设置为在30天后使对象过期。

票数 5
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/65395564

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档