Mah*_*ari 8 reactjs graphql aws-amplify
我有一个简单的全栈放大应用程序。
\n这是我的模型:
\ntype Note @model @auth(rules: [{allow: public}]) {\n id: ID!\n name: String!\n description: String\n image: String\n NoteType: NoteType @connection\n}\n\ntype NoteType @model @auth(rules: [{allow: public}]) {\n id: ID!\n name: String!\n}\nRun Code Online (Sandbox Code Playgroud)\n我正在尝试删除具有以下有效负载的注释:
\ntype Note @model @auth(rules: [{allow: public}]) {\n id: ID!\n name: String!\n description: String\n image: String\n NoteType: NoteType @connection\n}\n\ntype NoteType @model @auth(rules: [{allow: public}]) {\n id: ID!\n name: String!\n}\nRun Code Online (Sandbox Code Playgroud)\n我在响应中看到的是以下 json:
\n{\n "query": "mutation DeleteNote($input: DeleteNoteInput!, $condition: ModelNoteConditionInput) {\xe2\x86\xb5 deleteNote(input: $input, condition: $condition) {\xe2\x86\xb5 id\xe2\x86\xb5 name\xe2\x86\xb5 description\xe2\x86\xb5 image\xe2\x86\xb5 createdAt\xe2\x86\xb5 updatedAt\xe2\x86\xb5 NoteType {\xe2\x86\xb5 id\xe2\x86\xb5 name\xe2\x86\xb5 createdAt\xe2\x86\xb5 updatedAt\xe2\x86\xb5 }\xe2\x86\xb5 }\xe2\x86\xb5}\xe2\x86\xb5",\n "variables": {"input": {"id": "0c5e3ced-ffa3-4de8-9010-40b67d5bab68"}}\n}\nRun Code Online (Sandbox Code Playgroud)\n该代码一直有效,直到我尝试添加NoteType!这里的外键有冲突吗?
小智 18
使用 ConflictResolution 时,您还需要包含 _version 字段。
\n{\n "query": "mutation DeleteNote($input: DeleteNoteInput!, $condition: ModelNoteConditionInput) {\xe2\x86\xb5 deleteNote(input: $input, condition: $condition) {\xe2\x86\xb5 id\xe2\x86\xb5 name\xe2\x86\xb5 description\xe2\x86\xb5 image\xe2\x86\xb5 createdAt\xe2\x86\xb5 updatedAt\xe2\x86\xb5 NoteType {\xe2\x86\xb5 id\xe2\x86\xb5 name\xe2\x86\xb5 createdAt\xe2\x86\xb5 updatedAt\xe2\x86\xb5 }\xe2\x86\xb5 }\xe2\x86\xb5}\xe2\x86\xb5",\n "variables": {"input": {"id": "0c5e3ced-ffa3-4de8-9010-40b67d5bab68", "_version": "_version value of your note object"}}\n}\nRun Code Online (Sandbox Code Playgroud)\n我还注意到,删除使用 ConflictResolution 的元素后,它们不会立即从数据库中删除。相反,添加了两个标志:_deleted设置为 true 并_ttl设置为在 30 天后使对象过期。
| 归档时间: |
|
| 查看次数: |
5953 次 |
| 最近记录: |