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
required: false,
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)
issue = authorized_find!(project_path: project_path, iid: iid)
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 {
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
"""
......@@ -19012,6 +19027,11 @@ input UpdateIssueInput {
"""
removeLabelIds: [ID!]
"""
Close or reopen an issue.
"""
stateEvent: IssueStateEvent
"""
Title of the issue
"""
......
......@@ -25789,6 +25789,29 @@
],
"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",
"name": "IssueStatusCountsType",
......@@ -55396,6 +55419,16 @@
},
"defaultValue": null
},
{
"name": "stateEvent",
"description": "Close or reopen an issue.",
"type": {
"kind": "ENUM",
"name": "IssueStateEvent",
"ofType": null
},
"defaultValue": null
},
{
"name": "healthStatus",
"description": "The desired health status",
......@@ -3304,6 +3304,15 @@ State of a GitLab issue.
| `locked` | |
| `opened` | |
### IssueStateEvent
Values for issue state events.
| Value | Description |
| ----- | ----------- |
| `CLOSE` | Closes the issue |
| `REOPEN` | Reopens the issue |
### IssueType
Issue type.
......
......@@ -70,6 +70,23 @@ RSpec.describe Mutations::Issues::Update do
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
let_it_be(:label_1) { 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