Skip to content

Add GraphQL mutation for toggling the resolved status of a discussion

Luke Duncalfe requested to merge 13049-graphql-resolve-discussion into master

What does this MR do?

This MR adds a new GraphQL mutations for toggling the resolved state of a discussion.

It also adds a new interface called ResolvableInterface that is implemented by NoteType and DiscussionType. Previously NoteType had all the fields of this new interface, besides the boolean resolved. The interface allows us to reuse those field definitions between these two "resolvable" types.

Example mutation call

The following can be performed in GraphiQL to manually test the mutations.

  • input.id is the Global ID (emitted in GraphQL queries) of a discussion.
  • input.resolve is a boolean to indicate if the mutation should resolve or unresolve a discussion.

Note that the mutation will intentionally not produce an error if the input.resolved argument is true and the discussion is already resolved (and vice versa) this is to cater for the kind of race conditions that can happen when two clients are mutating the same discussion without the state having been refreshed on the second client to mutate beforehand. The client should not need to deal with errors in that situation, but simply know that the discussion was resolved (it may just not be by them).

mutation {
  discussionToggleResolve(input: { id: "gid://gitlab/DiffDiscussion/c6bd13b7c9814f1f5f77aa2b8ccef7fd37ea2f1a", resolve: true }) {
    discussion {
      id
      resolved
      resolvable
      resolvedAt
      resolvedBy {
        username
      }
      resolvedAt
      notes {
        nodes {
          resolved
          resolvable
          resolvedAt
          resolvedBy {
            username
          }
        }
      }
    }
    errors
  }
}

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Edited by 🤖 GitLab Bot 🤖

Merge request reports

Loading