I have the below as a snippet of my schema:
type Developer {
id: String! @id
name: String! @search(by: [exact])
mergesAssigned: [MergeRequest] @hasInverse(field: assignees)
mergesAuthorOf: [MergeRequest] @hasInverse(field: author)
}
type MergeRequest {
id: String! @id
title: String!
assignees: [Developer] @hasInverse(field: mergesAssigned)
author: Developer
}
When doing a batch upsert mutation (seen below), I am unable to upsert 2 nodes if the mergesAssigned and mergesAuthorOf reference the same MergeRequest.
mutation { resp: addDeveloper(input: [
{ id: "gid://gitlab/User/3921" mergesAssigned: [ { id: "gid://gitlab/MergeRequest/346409" } ] mergesAuthorOf: [] name: "Bob's Ur Uncle" },
{ id: "gid://gitlab/User/9595" mergesAssigned: [] mergesAuthorOf: [ { id: "gid://gitlab/MergeRequest/346409" } ] name: "Johnny Tables" },
], upsert: true) { entities: developer { id } }
}
Error given:
couldn't rewrite mutation addDeveloper because failed to rewrite mutation payload because duplicate XID found
However, the following mutation gives me no problems:
mutation { resp: addDeveloper(input: [
{ id: "gid://gitlab/User/3921" mergesAssigned: [ { id: "gid://gitlab/MergeRequest/346409" } ] mergesAuthorOf: [] name: "Bob's Ur Uncle" },
{ id: "gid://gitlab/User/9595" mergesAssigned: [ { id: "gid://gitlab/MergeRequest/346409" } ] mergesAuthorOf: [] name: "Johnny Tables" },
], upsert: true) { entities: developer { id } }
}
Is this a DGraph problem or a data modelling problem? I feel more likely the latter - if this is the case, I’d be very thankful for any guidance.