Commit 5cbb5782 authored by Felipe Artur's avatar Felipe Artur

Add arguments to UpdateIssue mutation

Add title, description, confidential, due_date arguments
to GraphQL UpdateIssue mutation
parent 5145de2d
......@@ -5,7 +5,25 @@ module Mutations
class Update < Base
graphql_name 'UpdateIssue'
# Add arguments here instead of creating separate mutations
argument :title,
GraphQL::STRING_TYPE,
required: false,
description: copy_field_description(Types::IssueType, :title)
argument :description,
GraphQL::STRING_TYPE,
required: false,
description: copy_field_description(Types::IssueType, :description)
argument :due_date,
Types::TimeType,
required: true,
description: copy_field_description(Types::IssueType, :due_date)
argument :confidential,
GraphQL::BOOLEAN_TYPE,
required: true,
description: copy_field_description(Types::IssueType, :confidential)
def resolve(project_path:, iid:, **args)
issue = authorized_find!(project_path: project_path, iid: iid)
......
---
title: Add missing arguments to UpdateIssue mutation
merge_request: 25268
author:
type: added
......@@ -7841,6 +7841,21 @@ input UpdateIssueInput {
"""
clientMutationId: String
"""
Indicates the issue is confidential
"""
confidential: Boolean!
"""
Description of the issue
"""
description: String
"""
Due date of the issue
"""
dueDate: Time!
"""
The desired health status
"""
......@@ -7855,6 +7870,11 @@ input UpdateIssueInput {
The project the issue to mutate is in
"""
projectPath: ID!
"""
Title of the issue
"""
title: String
}
"""
......
......@@ -20696,6 +20696,54 @@
},
"defaultValue": null
},
{
"name": "title",
"description": "Title of the issue",
"type": {
"kind": "SCALAR",
"name": "String",
"ofType": null
},
"defaultValue": null
},
{
"name": "description",
"description": "Description of the issue",
"type": {
"kind": "SCALAR",
"name": "String",
"ofType": null
},
"defaultValue": null
},
{
"name": "dueDate",
"description": "Due date of the issue",
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "Time",
"ofType": null
}
},
"defaultValue": null
},
{
"name": "confidential",
"description": "Indicates the issue is confidential",
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "Boolean",
"ofType": null
}
},
"defaultValue": null
},
{
"name": "healthStatus",
"description": "The desired health status",
......
# frozen_string_literal: true
require 'spec_helper'
describe Mutations::Issues::Update do
let(:issue) { create(:issue) }
let(:user) { create(:user) }
let(:expected_attributes) do
{
title: 'new title',
description: 'new description',
confidential: true,
due_date: Date.tomorrow
}
end
let(:mutation) { described_class.new(object: nil, context: { current_user: user }) }
let(:mutated_issue) { subject[:issue] }
describe '#resolve' do
let(:mutation_params) do
{
project_path: issue.project.full_path,
iid: issue.iid
}.merge(expected_attributes)
end
subject { mutation.resolve(mutation_params) }
it 'raises an error if the resource is not accessible to the user' do
expect { subject }.to raise_error(Gitlab::Graphql::Errors::ResourceNotAvailable)
end
context 'when the user can update the issue' do
before do
issue.project.add_developer(user)
end
it 'updates issue with correct values' do
subject
expect(issue.reload).to have_attributes(expected_attributes)
end
context 'when iid does not exist' do
it 'raises resource not available error' do
mutation_params[:iid] = 99999
expect { subject }.to raise_error(Gitlab::Graphql::Errors::ResourceNotAvailable)
end
end
end
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