Commit eb18a2c9 authored by Sean McGivern's avatar Sean McGivern

Merge branch 'issue_233479-allow-graphql-to-update-issue-state' into 'master'

Allow to update issue state on GraphQL

See merge request gitlab-org/gitlab!44061
parents ec0bc658 ec0dfbe7
...@@ -46,6 +46,10 @@ module Mutations ...@@ -46,6 +46,10 @@ module Mutations
required: false, required: false,
description: 'The ID of the milestone to be assigned, milestone will be removed if set to null.' description: 'The ID of the milestone to be assigned, milestone will be removed if set to null.'
argument :state_event, Types::IssueStateEventEnum,
description: 'Close or reopen an issue.',
required: false
def resolve(project_path:, iid:, **args) def resolve(project_path:, iid:, **args)
issue = authorized_find!(project_path: project_path, iid: iid) issue = authorized_find!(project_path: project_path, iid: iid)
project = issue.project project = issue.project
......
# frozen_string_literal: true
module Types
class IssueStateEventEnum < BaseEnum
graphql_name 'IssueStateEvent'
description 'Values for issue state events'
value 'REOPEN', 'Reopens the issue', value: 'reopen'
value 'CLOSE', 'Closes the issue', value: 'close'
end
end
---
title: Allow to update issue state on GraphQL
merge_request: 44061
author:
type: added
...@@ -9429,6 +9429,21 @@ enum IssueState { ...@@ -9429,6 +9429,21 @@ enum IssueState {
opened opened
} }
"""
Values for issue state events
"""
enum IssueStateEvent {
"""
Closes the issue
"""
CLOSE
"""
Reopens the issue
"""
REOPEN
}
""" """
Represents total number of issues for the represented statuses Represents total number of issues for the represented statuses
""" """
...@@ -19012,6 +19027,11 @@ input UpdateIssueInput { ...@@ -19012,6 +19027,11 @@ input UpdateIssueInput {
""" """
removeLabelIds: [ID!] removeLabelIds: [ID!]
"""
Close or reopen an issue.
"""
stateEvent: IssueStateEvent
""" """
Title of the issue Title of the issue
""" """
......
...@@ -25789,6 +25789,29 @@ ...@@ -25789,6 +25789,29 @@
], ],
"possibleTypes": null "possibleTypes": null
}, },
{
"kind": "ENUM",
"name": "IssueStateEvent",
"description": "Values for issue state events",
"fields": null,
"inputFields": null,
"interfaces": null,
"enumValues": [
{
"name": "REOPEN",
"description": "Reopens the issue",
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "CLOSE",
"description": "Closes the issue",
"isDeprecated": false,
"deprecationReason": null
}
],
"possibleTypes": null
},
{ {
"kind": "OBJECT", "kind": "OBJECT",
"name": "IssueStatusCountsType", "name": "IssueStatusCountsType",
...@@ -55396,6 +55419,16 @@ ...@@ -55396,6 +55419,16 @@
}, },
"defaultValue": null "defaultValue": null
}, },
{
"name": "stateEvent",
"description": "Close or reopen an issue.",
"type": {
"kind": "ENUM",
"name": "IssueStateEvent",
"ofType": null
},
"defaultValue": null
},
{ {
"name": "healthStatus", "name": "healthStatus",
"description": "The desired health status", "description": "The desired health status",
...@@ -3304,6 +3304,15 @@ State of a GitLab issue. ...@@ -3304,6 +3304,15 @@ State of a GitLab issue.
| `locked` | | | `locked` | |
| `opened` | | | `opened` | |
### IssueStateEvent
Values for issue state events.
| Value | Description |
| ----- | ----------- |
| `CLOSE` | Closes the issue |
| `REOPEN` | Reopens the issue |
### IssueType ### IssueType
Issue type. Issue type.
......
...@@ -70,6 +70,23 @@ RSpec.describe Mutations::Issues::Update do ...@@ -70,6 +70,23 @@ RSpec.describe Mutations::Issues::Update do
end end
end end
context 'when changing state' do
let_it_be_with_refind(:issue) { create(:issue, project: project, state: :opened) }
it 'closes issue' do
mutation_params[:state_event] = 'close'
expect { subject }.to change { issue.reload.state }.from('opened').to('closed')
end
it 'reopens issue' do
issue.close
mutation_params[:state_event] = 'reopen'
expect { subject }.to change { issue.reload.state }.from('closed').to('opened')
end
end
context 'when changing labels' do context 'when changing labels' do
let_it_be(:label_1) { create(:label, project: project) } let_it_be(:label_1) { create(:label, project: project) }
let_it_be(:label_2) { create(:label, project: project) } let_it_be(:label_2) { create(:label, project: project) }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment