Commit aebdffde authored by Robert Speicher's avatar Robert Speicher

Merge branch '229506-graphql-mutation-for-adding-epic-to-issue-2' into 'master'

Change IssueSetEpic mutation to make epic_id argument not required

See merge request gitlab-org/gitlab!39451
parents f768881a 0c57932f
......@@ -7355,9 +7355,9 @@ input IssueSetEpicInput {
clientMutationId: String
"""
Global ID of the epic to be assigned to the issue
Global ID of the epic to be assigned to the issue, epic will be removed if absent or set to null
"""
epicId: ID!
epicId: ID
"""
The IID of the issue to mutate
......
......@@ -20359,15 +20359,11 @@
},
{
"name": "epicId",
"description": "Global ID of the epic to be assigned to the issue",
"description": "Global ID of the epic to be assigned to the issue, epic will be removed if absent or set to null",
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "ID",
"ofType": null
}
"kind": "SCALAR",
"name": "ID",
"ofType": null
},
"defaultValue": null
},
......@@ -7,9 +7,10 @@ module Mutations
argument :epic_id,
GraphQL::ID_TYPE,
required: true,
required: false,
loads: Types::EpicType,
description: 'Global ID of the epic to be assigned to the issue'
description: 'Global ID of the epic to be assigned to the issue, ' \
'epic will be removed if absent or set to null'
def resolve(project_path:, iid:, epic: nil)
issue = authorized_find!(project_path: project_path, iid: iid)
......
---
title: Change IssueSetEpic mutation to make epic_id argument not required
merge_request: 39451
author:
type: changed
......@@ -5,12 +5,12 @@ require 'spec_helper'
RSpec.describe 'Setting the epic of an issue' do
include GraphqlHelpers
let(:current_user) { create(:user) }
let(:group) { create(:group) }
let(:epic) { create(:epic, group: group) }
let(:project) { create(:project, group: group) }
let(:issue) { create(:issue, project: project) }
let(:input) { { epic_id: global_id_of(epic) } }
let_it_be(:current_user) { create(:user) }
let_it_be(:group) { create(:group) }
let_it_be(:epic) { create(:epic, group: group) }
let_it_be(:project) { create(:project, group: group) }
let_it_be(:issue) { create(:issue, project: project, epic: create(:epic, group: group)) }
let_it_be(:input) { { epic_id: global_id_of(epic) } }
let(:mutation) do
graphql_mutation(
......@@ -65,4 +65,12 @@ RSpec.describe 'Setting the epic of an issue' do
expect(mutation_response['issue']['epic']['title']).to eq(epic.title)
expect(issue.reload.epic).to eq(epic)
end
it 'removes existing epic if epic_id is nil' do
input[:epic_id] = nil
post_graphql_mutation(mutation, current_user: current_user)
expect(response).to have_gitlab_http_status(:success)
expect(issue.reload.epic).to be_nil
end
end
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