GraphQL `createDiffNote` mutation doesn't fully support interactive clients
Summary
When we create a diff note (comment) through the GraphQL endpoint, we get back a response with only the note. That is not enough if the client is interactive (e.g. GitLab VS Code Extension).
Interactive clients need to have access to the discussion (parent entity) so the user can respond or resolve that discussion.
The following screenshot shows the features that are related to a discussion and not the note. These features are not available when the client uses the createDiffNote mutation to create a note.
*I use bug template for its simplicity, but I assume this is ~"feature::maintenance".
Steps to reproduce
(inspect the types and try the mutation in https://gitlab.com/-/graphql-explorer)
Mutation:
mutation CreateDiffNote {
createDiffNote(
input: {
noteableId: "gid://gitlab/MergeRequest/87196674"
body: "new note"
position: {
baseSha: "5e6dffa282c5129aa67cd227a0429be21bfdaf80"
headSha: "a2616e0fea06c8b5188e4064a76d623afbf97b0c"
startSha: "5e6dffa282c5129aa67cd227a0429be21bfdaf80"
paths: { newPath: "/test.ts", oldPath: "/test.js" }
newLine: 15
}
}
) {
errors
note {
id
}
}
}
returns a Note.
But we need the discussion, instead of the note, because only the discussion (parent object) contains replyId which is used for resovling and replying to a discussion
Example Project
I use https://gitlab.com/viktomas/test-project
Possible fixes
We can either return discussion and deprecate the returned note or we can introduce a new endpoint.
If we are introducing the new endpoint, the CreateDiffNotePayload should be redesigned to be identical to the position property of a note. It's going to have much less cognitive tax on API users.
Current workaround
Since interactive clients need to know the discussion after creating a new diff note, we have to query all discussions and filter out the one that contains the created note.
