Reputation: 95
I have a many-to-many relationship in amplify with the following schema
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"])
}
And when I try to delete a BlogTag entry, I get the following error:
message: "Conflict resolver rejects mutation."
path: ["deleteBlogTag"]
I try to delete the entry with the following code:
import { API } from "aws-amplify";
import {deleteBlogTag} from "../graphql/mutations";
...
await API.graphql({
query: deleteBlogTag,
variables: { input: { id: blogTagId } },
});
I don't understand why there would be a conflict. If I were deleting a blog, and there'd be BlogTags pointing to that blog, then of course that's a conflict. But why is it a conflict deleting a BlogTag? Is it something I am missing in the schema?
Upvotes: 0
Views: 1144
Reputation: 21
You need to provide _version parameter, i.e
await API.graphql({
query: deleteBlogTag,
variables: { input: { id: blogTagId, _version: version } },
});
But I would suggest to go through amplify update api
and remove sync conflict resolution.
Upvotes: 1