Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
9d6e0610
Commit
9d6e0610
authored
Jul 15, 2020
by
John Hope
Committed by
Bob Van Landuyt
Jul 15, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Resolve "GraphQL: Mutation for changing locked status of an issue"
parent
7ce7a8a3
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
346 additions
and
0 deletions
+346
-0
app/graphql/mutations/issues/set_locked.rb
app/graphql/mutations/issues/set_locked.rb
+26
-0
app/graphql/types/mutation_type.rb
app/graphql/types/mutation_type.rb
+1
-0
changelogs/unreleased/36319-graphql-mutation-for-changing-locked-status-of-an-issue.yml
...aphql-mutation-for-changing-locked-status-of-an-issue.yml
+5
-0
doc/api/graphql/reference/gitlab_schema.graphql
doc/api/graphql/reference/gitlab_schema.graphql
+46
-0
doc/api/graphql/reference/gitlab_schema.json
doc/api/graphql/reference/gitlab_schema.json
+157
-0
doc/api/graphql/reference/index.md
doc/api/graphql/reference/index.md
+10
-0
spec/graphql/mutations/issues/set_locked_spec.rb
spec/graphql/mutations/issues/set_locked_spec.rb
+46
-0
spec/requests/api/graphql/mutations/issues/set_locked_spec.rb
.../requests/api/graphql/mutations/issues/set_locked_spec.rb
+55
-0
No files found.
app/graphql/mutations/issues/set_locked.rb
0 → 100644
View file @
9d6e0610
# frozen_string_literal: true
module
Mutations
module
Issues
class
SetLocked
<
Base
graphql_name
'IssueSetLocked'
argument
:locked
,
GraphQL
::
BOOLEAN_TYPE
,
required:
true
,
description:
'Whether or not to lock discussion on the issue'
def
resolve
(
project_path
:,
iid
:,
locked
:)
issue
=
authorized_find!
(
project_path:
project_path
,
iid:
iid
)
::
Issues
::
UpdateService
.
new
(
issue
.
project
,
current_user
,
discussion_locked:
locked
)
.
execute
(
issue
)
{
issue:
issue
,
errors:
errors_on_object
(
issue
)
}
end
end
end
end
app/graphql/types/mutation_type.rb
View file @
9d6e0610
...
...
@@ -17,6 +17,7 @@ module Types
mount_mutation
Mutations
::
Commits
::
Create
,
calls_gitaly:
true
mount_mutation
Mutations
::
Discussions
::
ToggleResolve
mount_mutation
Mutations
::
Issues
::
SetConfidential
mount_mutation
Mutations
::
Issues
::
SetLocked
mount_mutation
Mutations
::
Issues
::
SetDueDate
mount_mutation
Mutations
::
Issues
::
Update
mount_mutation
Mutations
::
MergeRequests
::
Create
...
...
changelogs/unreleased/36319-graphql-mutation-for-changing-locked-status-of-an-issue.yml
0 → 100644
View file @
9d6e0610
---
title
:
'
GraphQL
mutation
for
changing
locked
status
of
an
issue'
merge_request
:
36866
author
:
type
:
added
doc/api/graphql/reference/gitlab_schema.graphql
View file @
9d6e0610
...
...
@@ -6178,6 +6178,51 @@ type IssueSetIterationPayload {
issue
:
Issue
}
"""
Autogenerated input type of IssueSetLocked
"""
input
IssueSetLockedInput
{
"""
A
unique
identifier
for
the
client
performing
the
mutation
.
"""
clientMutationId
:
String
"""
The
iid
of
the
issue
to
mutate
"""
iid
:
String
!
"""
Whether
or
not
to
lock
discussion
on
the
issue
"""
locked
:
Boolean
!
"""
The
project
the
issue
to
mutate
is
in
"""
projectPath
:
ID
!
}
"""
Autogenerated return type of IssueSetLocked
"""
type
IssueSetLockedPayload
{
"""
A
unique
identifier
for
the
client
performing
the
mutation
.
"""
clientMutationId
:
String
"""
Errors
encountered
during
execution
of
the
mutation
.
"""
errors
:
[
String
!]!
"""
The
issue
after
mutation
"""
issue
:
Issue
}
"""
Autogenerated input type of IssueSetWeight
"""
...
...
@@ -8087,6 +8132,7 @@ type Mutation {
issueSetConfidential
(
input
:
IssueSetConfidentialInput
!):
IssueSetConfidentialPayload
issueSetDueDate
(
input
:
IssueSetDueDateInput
!):
IssueSetDueDatePayload
issueSetIteration
(
input
:
IssueSetIterationInput
!):
IssueSetIterationPayload
issueSetLocked
(
input
:
IssueSetLockedInput
!):
IssueSetLockedPayload
issueSetWeight
(
input
:
IssueSetWeightInput
!):
IssueSetWeightPayload
jiraImportStart
(
input
:
JiraImportStartInput
!):
JiraImportStartPayload
jiraImportUsers
(
input
:
JiraImportUsersInput
!):
JiraImportUsersPayload
...
...
doc/api/graphql/reference/gitlab_schema.json
View file @
9d6e0610
...
...
@@ -17078,6 +17078,136 @@
"enumValues": null,
"possibleTypes": null
},
{
"kind": "INPUT_OBJECT",
"name": "IssueSetLockedInput",
"description": "Autogenerated input type of IssueSetLocked",
"fields": null,
"inputFields": [
{
"name": "projectPath",
"description": "The project the issue to mutate is in",
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "ID",
"ofType": null
}
},
"defaultValue": null
},
{
"name": "iid",
"description": "The iid of the issue to mutate",
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "String",
"ofType": null
}
},
"defaultValue": null
},
{
"name": "locked",
"description": "Whether or not to lock discussion on the issue",
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "Boolean",
"ofType": null
}
},
"defaultValue": null
},
{
"name": "clientMutationId",
"description": "A unique identifier for the client performing the mutation.",
"type": {
"kind": "SCALAR",
"name": "String",
"ofType": null
},
"defaultValue": null
}
],
"interfaces": null,
"enumValues": null,
"possibleTypes": null
},
{
"kind": "OBJECT",
"name": "IssueSetLockedPayload",
"description": "Autogenerated return type of IssueSetLocked",
"fields": [
{
"name": "clientMutationId",
"description": "A unique identifier for the client performing the mutation.",
"args": [
],
"type": {
"kind": "SCALAR",
"name": "String",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "errors",
"description": "Errors encountered during execution of the mutation.",
"args": [
],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "LIST",
"name": null,
"ofType": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "String",
"ofType": null
}
}
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "issue",
"description": "The issue after mutation",
"args": [
],
"type": {
"kind": "OBJECT",
"name": "Issue",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
}
],
"inputFields": null,
"interfaces": [
],
"enumValues": null,
"possibleTypes": null
},
{
"kind": "INPUT_OBJECT",
"name": "IssueSetWeightInput",
...
...
@@ -23457,6 +23587,33 @@
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "issueSetLocked",
"description": null,
"args": [
{
"name": "input",
"description": null,
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "INPUT_OBJECT",
"name": "IssueSetLockedInput",
"ofType": null
}
},
"defaultValue": null
}
],
"type": {
"kind": "OBJECT",
"name": "IssueSetLockedPayload",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "issueSetWeight",
"description": null,
doc/api/graphql/reference/index.md
View file @
9d6e0610
...
...
@@ -928,6 +928,16 @@ Autogenerated return type of IssueSetIteration
|
`errors`
| String! => Array | Errors encountered during execution of the mutation. |
|
`issue`
| Issue | The issue after mutation |
## IssueSetLockedPayload
Autogenerated return type of IssueSetLocked
| Name | Type | Description |
| --- | ---- | ---------- |
|
`clientMutationId`
| String | A unique identifier for the client performing the mutation. |
|
`errors`
| String! => Array | Errors encountered during execution of the mutation. |
|
`issue`
| Issue | The issue after mutation |
## IssueSetWeightPayload
Autogenerated return type of IssueSetWeight
...
...
spec/graphql/mutations/issues/set_locked_spec.rb
0 → 100644
View file @
9d6e0610
# frozen_string_literal: true
require
'spec_helper'
RSpec
.
describe
Mutations
::
Issues
::
SetLocked
do
let_it_be
(
:issue
)
{
create
(
:issue
)
}
let_it_be
(
:user
)
{
create
(
:user
)
}
subject
(
:mutation
)
{
described_class
.
new
(
object:
nil
,
context:
{
current_user:
user
},
field:
nil
)
}
specify
{
expect
(
described_class
).
to
require_graphql_authorizations
(
:update_issue
)
}
describe
'#resolve'
do
let
(
:locked
)
{
true
}
subject
{
mutation
.
resolve
(
project_path:
issue
.
project
.
full_path
,
iid:
issue
.
iid
,
locked:
locked
)
}
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
let
(
:mutated_issue
)
{
subject
[
:issue
]
}
before
do
issue
.
project
.
add_developer
(
user
)
end
it
'returns the issue as discussion locked'
do
expect
(
mutated_issue
).
to
eq
(
issue
)
expect
(
mutated_issue
).
to
be_discussion_locked
expect
(
subject
[
:errors
]).
to
be_empty
end
context
'when passing locked as false'
do
let
(
:locked
)
{
false
}
it
'unlocks the discussion'
do
issue
.
update!
(
discussion_locked:
true
)
expect
(
mutated_issue
).
not_to
be_discussion_locked
end
end
end
end
end
spec/requests/api/graphql/mutations/issues/set_locked_spec.rb
0 → 100644
View file @
9d6e0610
# frozen_string_literal: true
require
'spec_helper'
RSpec
.
describe
'Setting an issue as locked'
do
include
GraphqlHelpers
let_it_be
(
:current_user
)
{
create
(
:user
)
}
let_it_be
(
:issue
)
{
create
(
:issue
)
}
let_it_be
(
:project
)
{
issue
.
project
}
let
(
:input
)
{
{
locked:
true
}
}
let
(
:mutation
)
do
variables
=
{
project_path:
project
.
full_path
,
iid:
issue
.
iid
.
to_s
}
graphql_mutation
(
:issue_set_locked
,
variables
.
merge
(
input
),
<<-
QL
.
strip_heredoc
clientMutationId
errors
issue {
iid
discussionLocked
}
QL
)
end
def
mutation_response
graphql_mutation_response
(
:issue_set_locked
)
end
context
'when the user is not allowed to update the issue'
do
it
'returns an error'
do
error
=
"The resource that you are attempting to access does not exist or you don't have permission to perform this action"
post_graphql_mutation
(
mutation
,
current_user:
current_user
)
expect
(
graphql_errors
).
to
include
(
a_hash_including
(
'message'
=>
error
))
end
end
context
'when user is allowed to update the issue'
do
before
do
project
.
add_developer
(
current_user
)
end
it
'updates the issue locked status'
do
post_graphql_mutation
(
mutation
,
current_user:
current_user
)
expect
(
response
).
to
have_gitlab_http_status
(
:success
)
expect
(
mutation_response
[
'issue'
][
'discussionLocked'
]).
to
be_truthy
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment