我与以下架构有一个多对多的关系
type Blog
@model
@searchable
{
id: ID!
title: String!
tags: [BlogTag] @connection(keyName: "byBlog", fields: ["id"])
}
type Tag
@model
@searchable
{
id: ID!
name: String!
blogs: [BlogTag] @connection(keyName: "byTag", fields: ["id"])
}
type BlogTag
@model
@key(name: "byBlog", fields: ["blogID", "tagID"])
@key(name: "byTag", fields: ["tagID", "blogID"])
{
id: ID!
blogID: ID!
tagID: ID!
blog: Blog! @connection(fields: ["blogID"])
tag: Tag! @connection(fields: ["tagID"])
}
当我尝试删除 BlogTag 条目时,我收到以下错误:
message: "Conflict resolver rejects mutation."
path: ["deleteBlogTag"]
我尝试使用以下代码删除条目:
import { API } from "aws-amplify";
import {deleteBlogTag} from "../graphql/mutations";
...
await API.graphql({
query: deleteBlogTag,
variables: { input: { id: blogTagId } },
});
我不明白为什么会有冲突。如果我正在删除一个博客,并且会有指向该博客的 BlogTags,那么这当然是一个冲突。但是为什么删除 BlogTag 会发生冲突?这是我在架构中缺少的东西吗?