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
b7fa6599
Commit
b7fa6599
authored
Apr 07, 2021
by
Felipe Artur
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow to update epic boards lists with GraphQL
Introduces epic boards update mutation on graphql
parent
0463eb5a
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
233 additions
and
109 deletions
+233
-109
app/graphql/mutations/boards/lists/base_update.rb
app/graphql/mutations/boards/lists/base_update.rb
+40
-0
app/graphql/mutations/boards/lists/update.rb
app/graphql/mutations/boards/lists/update.rb
+1
-21
doc/api/graphql/reference/index.md
doc/api/graphql/reference/index.md
+10
-0
ee/app/graphql/ee/types/mutation_type.rb
ee/app/graphql/ee/types/mutation_type.rb
+1
-0
ee/app/graphql/mutations/boards/epic_lists/update.rb
ee/app/graphql/mutations/boards/epic_lists/update.rb
+32
-0
ee/changelogs/unreleased/issue_321770-add_graphql_mutation.yml
...angelogs/unreleased/issue_321770-add_graphql_mutation.yml
+5
-0
ee/spec/graphql/mutations/boards/epic_lists/update_spec.rb
ee/spec/graphql/mutations/boards/epic_lists/update_spec.rb
+20
-0
ee/spec/requests/api/graphql/boards/epic_lists/update_spec.rb
...pec/requests/api/graphql/boards/epic_lists/update_spec.rb
+23
-0
spec/graphql/mutations/boards/lists/update_spec.rb
spec/graphql/mutations/boards/lists/update_spec.rb
+9
-49
spec/requests/api/graphql/mutations/boards/lists/update_spec.rb
...equests/api/graphql/mutations/boards/lists/update_spec.rb
+1
-39
spec/support/shared_examples/graphql/mutations/boards/update_list_shared_examples.rb
...s/graphql/mutations/boards/update_list_shared_examples.rb
+48
-0
spec/support/shared_examples/requests/api/graphql/mutations/boards/update_list_shared_examples.rb
...i/graphql/mutations/boards/update_list_shared_examples.rb
+43
-0
No files found.
app/graphql/mutations/boards/lists/base_update.rb
0 → 100644
View file @
b7fa6599
# frozen_string_literal: true
module
Mutations
module
Boards
module
Lists
class
BaseUpdate
<
BaseMutation
argument
:position
,
GraphQL
::
INT_TYPE
,
required:
false
,
description:
'Position of list within the board.'
argument
:collapsed
,
GraphQL
::
BOOLEAN_TYPE
,
required:
false
,
description:
'Indicates if the list is collapsed for this user.'
def
resolve
(
list:
nil
,
**
args
)
if
list
.
nil?
||
!
can_read_list?
(
list
)
raise_resource_not_available_error!
end
update_result
=
update_list
(
list
,
args
)
{
list:
update_result
[
:list
],
errors:
list
.
errors
.
full_messages
}
end
private
def
update_list
(
list
,
args
)
raise
NotImplementedError
end
def
can_read_list?
(
list
)
raise
NotImplementedError
end
end
end
end
end
app/graphql/mutations/boards/lists/update.rb
View file @
b7fa6599
...
...
@@ -3,7 +3,7 @@
module
Mutations
module
Boards
module
Lists
class
Update
<
Base
Mutation
class
Update
<
Base
Update
graphql_name
'UpdateBoardList'
argument
:list_id
,
Types
::
GlobalIDType
[
List
],
...
...
@@ -11,29 +11,11 @@ module Mutations
loads:
Types
::
BoardListType
,
description:
'Global ID of the list.'
argument
:position
,
GraphQL
::
INT_TYPE
,
required:
false
,
description:
'Position of list within the board.'
argument
:collapsed
,
GraphQL
::
BOOLEAN_TYPE
,
required:
false
,
description:
'Indicates if the list is collapsed for this user.'
field
:list
,
Types
::
BoardListType
,
null:
true
,
description:
'Mutated list.'
def
resolve
(
list:
nil
,
**
args
)
raise_resource_not_available_error!
unless
can_read_list?
(
list
)
update_result
=
update_list
(
list
,
args
)
{
list:
update_result
[
:list
],
errors:
list
.
errors
.
full_messages
}
end
private
def
update_list
(
list
,
args
)
...
...
@@ -42,8 +24,6 @@ module Mutations
end
def
can_read_list?
(
list
)
return
false
unless
list
.
present?
Ability
.
allowed?
(
current_user
,
:read_issue_board_list
,
list
.
board
)
end
end
...
...
doc/api/graphql/reference/index.md
View file @
b7fa6599
...
...
@@ -6777,6 +6777,16 @@ Autogenerated return type of UpdateContainerExpirationPolicy.
|
`containerExpirationPolicy`
|
[
`ContainerExpirationPolicy`
](
#containerexpirationpolicy
)
| The container expiration policy after mutation. |
|
`errors`
|
[
`[String!]!`
](
#string
)
| Errors encountered during execution of the mutation. |
### `UpdateEpicBoardListPayload`
Autogenerated return type of UpdateEpicBoardList.
| Field | Type | Description |
| ----- | ---- | ----------- |
|
`clientMutationId`
|
[
`String`
](
#string
)
| A unique identifier for the client performing the mutation. |
|
`errors`
|
[
`[String!]!`
](
#string
)
| Errors encountered during execution of the mutation. |
|
`list`
|
[
`EpicList`
](
#epiclist
)
| Mutated epic list. |
### `UpdateEpicPayload`
Autogenerated return type of UpdateEpic.
...
...
ee/app/graphql/ee/types/mutation_type.rb
View file @
b7fa6599
...
...
@@ -43,6 +43,7 @@ module EE
mount_mutation
::
Mutations
::
Boards
::
EpicBoards
::
EpicMoveList
mount_mutation
::
Mutations
::
Boards
::
EpicBoards
::
Update
mount_mutation
::
Mutations
::
Boards
::
EpicLists
::
Create
mount_mutation
::
Mutations
::
Boards
::
EpicLists
::
Update
mount_mutation
::
Mutations
::
Boards
::
Lists
::
UpdateLimitMetrics
mount_mutation
::
Mutations
::
InstanceSecurityDashboard
::
AddProject
mount_mutation
::
Mutations
::
InstanceSecurityDashboard
::
RemoveProject
...
...
ee/app/graphql/mutations/boards/epic_lists/update.rb
0 → 100644
View file @
b7fa6599
# frozen_string_literal: true
module
Mutations
module
Boards
module
EpicLists
class
Update
<
::
Mutations
::
Boards
::
Lists
::
BaseUpdate
graphql_name
'UpdateEpicBoardList'
argument
:list_id
,
Types
::
GlobalIDType
[
::
Boards
::
EpicList
],
required:
true
,
loads:
Types
::
Boards
::
EpicListType
,
description:
'Global ID of the epic list.'
field
:list
,
Types
::
Boards
::
EpicListType
,
null:
true
,
description:
'Mutated epic list.'
private
def
update_list
(
list
,
args
)
service
=
::
Boards
::
EpicLists
::
UpdateService
.
new
(
list
.
board
,
current_user
,
args
)
service
.
execute
(
list
)
end
def
can_read_list?
(
list
)
Ability
.
allowed?
(
current_user
,
:read_epic_board_list
,
list
.
board
)
end
end
end
end
end
ee/changelogs/unreleased/issue_321770-add_graphql_mutation.yml
0 → 100644
View file @
b7fa6599
---
title
:
Add GraphQL mutation that allows to update epic boards lists
merge_request
:
58782
author
:
type
:
added
ee/spec/graphql/mutations/boards/epic_lists/update_spec.rb
0 → 100644
View file @
b7fa6599
# frozen_string_literal: true
require
'spec_helper'
RSpec
.
describe
Mutations
::
Boards
::
EpicLists
::
Update
do
let_it_be
(
:group
)
{
create
(
:group
,
:private
)
}
let_it_be
(
:board
)
{
create
(
:epic_board
,
group:
group
)
}
let_it_be
(
:reporter
)
{
create
(
:user
)
}
let_it_be
(
:guest
)
{
create
(
:user
)
}
let_it_be
(
:list
)
{
create
(
:epic_list
,
epic_board:
board
,
position:
0
)
}
let_it_be
(
:list2
)
{
create
(
:epic_list
,
epic_board:
board
)
}
before
do
stub_licensed_features
(
epics:
true
)
end
context
'on epic boards'
do
it_behaves_like
'update board list mutation'
end
end
ee/spec/requests/api/graphql/boards/epic_lists/update_spec.rb
0 → 100644
View file @
b7fa6599
# frozen_string_literal: true
require
'spec_helper'
RSpec
.
describe
'Update of an existing epic board list'
do
include
GraphqlHelpers
let_it_be
(
:current_user
)
{
create
(
:user
)
}
let_it_be
(
:group
)
{
create
(
:group
,
:private
)
}
let_it_be
(
:board
)
{
create
(
:epic_board
,
group:
group
)
}
let_it_be
(
:list
)
{
create
(
:epic_list
,
epic_board:
board
,
position:
0
)
}
let_it_be
(
:list2
)
{
create
(
:epic_list
,
epic_board:
board
)
}
let_it_be
(
:input
)
{
{
list_id:
list
.
to_global_id
.
to_s
,
position:
1
,
collapsed:
true
}
}
let
(
:mutation
)
{
graphql_mutation
(
:update_epic_board_list
,
input
)
}
let
(
:mutation_response
)
{
graphql_mutation_response
(
:update_epic_board_list
)
}
before
do
stub_licensed_features
(
epics:
true
)
end
it_behaves_like
'a GraphQL request to update board list'
end
spec/graphql/mutations/boards/lists/update_spec.rb
View file @
b7fa6599
...
...
@@ -3,54 +3,14 @@
require
'spec_helper'
RSpec
.
describe
Mutations
::
Boards
::
Lists
::
Update
do
let_it_be
(
:group
)
{
create
(
:group
,
:private
)
}
let_it_be
(
:board
)
{
create
(
:board
,
group:
group
)
}
let_it_be
(
:reporter
)
{
create
(
:user
)
}
let_it_be
(
:guest
)
{
create
(
:user
)
}
let_it_be
(
:list
)
{
create
(
:list
,
board:
board
,
position:
0
)
}
let_it_be
(
:list2
)
{
create
(
:list
,
board:
board
)
}
let
(
:mutation
)
{
described_class
.
new
(
object:
nil
,
context:
{
current_user:
current_user
},
field:
nil
)
}
let
(
:list_update_params
)
{
{
position:
1
,
collapsed:
true
}
}
before_all
do
group
.
add_reporter
(
reporter
)
group
.
add_guest
(
guest
)
list
.
update_preferences_for
(
reporter
,
collapsed:
false
)
end
subject
{
mutation
.
resolve
(
list:
list
,
**
list_update_params
)
}
describe
'#resolve'
do
context
'with permission to admin board lists'
do
let
(
:current_user
)
{
reporter
}
it
'updates the list position and collapsed state as expected'
do
subject
reloaded_list
=
list
.
reload
expect
(
reloaded_list
.
position
).
to
eq
(
1
)
expect
(
reloaded_list
.
collapsed?
(
current_user
)).
to
eq
(
true
)
end
end
context
'with permission to read board lists'
do
let
(
:current_user
)
{
guest
}
it
'updates the list collapsed state but not the list position'
do
subject
reloaded_list
=
list
.
reload
expect
(
reloaded_list
.
position
).
to
eq
(
0
)
expect
(
reloaded_list
.
collapsed?
(
current_user
)).
to
eq
(
true
)
end
end
context
'without permission to read board lists'
do
let
(
:current_user
)
{
create
(
:user
)
}
it
'raises Resource Not Found error'
do
expect
{
subject
}.
to
raise_error
(
Gitlab
::
Graphql
::
Errors
::
ResourceNotAvailable
)
end
end
context
'on group issue boards'
do
let_it_be
(
:group
)
{
create
(
:group
,
:private
)
}
let_it_be
(
:board
)
{
create
(
:board
,
group:
group
)
}
let_it_be
(
:reporter
)
{
create
(
:user
)
}
let_it_be
(
:guest
)
{
create
(
:user
)
}
let_it_be
(
:list
)
{
create
(
:list
,
board:
board
,
position:
0
)
}
let_it_be
(
:list2
)
{
create
(
:list
,
board:
board
)
}
it_behaves_like
'update board list mutation'
end
end
spec/requests/api/graphql/mutations/boards/lists/update_spec.rb
View file @
b7fa6599
...
...
@@ -14,43 +14,5 @@ RSpec.describe 'Update of an existing board list' do
let
(
:mutation
)
{
graphql_mutation
(
:update_board_list
,
input
)
}
let
(
:mutation_response
)
{
graphql_mutation_response
(
:update_board_list
)
}
context
'the user is not allowed to read board lists'
do
it_behaves_like
'a mutation that returns a top-level access error'
end
before
do
list
.
update_preferences_for
(
current_user
,
collapsed:
false
)
end
context
'when user has permissions to admin board lists'
do
before
do
group
.
add_reporter
(
current_user
)
end
it
'updates the list position and collapsed state'
do
post_graphql_mutation
(
mutation
,
current_user:
current_user
)
expect
(
response
).
to
have_gitlab_http_status
(
:success
)
expect
(
mutation_response
[
'list'
]).
to
include
(
'position'
=>
1
,
'collapsed'
=>
true
)
end
end
context
'when user has permissions to read board lists'
do
before
do
group
.
add_guest
(
current_user
)
end
it
'updates the list collapsed state but not the list position'
do
post_graphql_mutation
(
mutation
,
current_user:
current_user
)
expect
(
response
).
to
have_gitlab_http_status
(
:success
)
expect
(
mutation_response
[
'list'
]).
to
include
(
'position'
=>
0
,
'collapsed'
=>
true
)
end
end
it_behaves_like
'a GraphQL request to update board list'
end
spec/support/shared_examples/graphql/mutations/boards/update_list_shared_examples.rb
0 → 100644
View file @
b7fa6599
# frozen_string_literal: true
RSpec
.
shared_examples
'update board list mutation'
do
describe
'#resolve'
do
let
(
:mutation
)
{
described_class
.
new
(
object:
nil
,
context:
{
current_user:
current_user
},
field:
nil
)
}
let
(
:list_update_params
)
{
{
position:
1
,
collapsed:
true
}
}
subject
{
mutation
.
resolve
(
list:
list
,
**
list_update_params
)
}
before_all
do
group
.
add_reporter
(
reporter
)
group
.
add_guest
(
guest
)
list
.
update_preferences_for
(
reporter
,
collapsed:
false
)
end
context
'with permission to admin board lists'
do
let
(
:current_user
)
{
reporter
}
it
'updates the list position and collapsed state as expected'
do
subject
reloaded_list
=
list
.
reload
expect
(
reloaded_list
.
position
).
to
eq
(
1
)
expect
(
reloaded_list
.
collapsed?
(
current_user
)).
to
eq
(
true
)
end
end
context
'with permission to read board lists'
do
let
(
:current_user
)
{
guest
}
it
'updates the list collapsed state but not the list position'
do
subject
reloaded_list
=
list
.
reload
expect
(
reloaded_list
.
position
).
to
eq
(
0
)
expect
(
reloaded_list
.
collapsed?
(
current_user
)).
to
eq
(
true
)
end
end
context
'without permission to read board lists'
do
let
(
:current_user
)
{
create
(
:user
)
}
it
'raises Resource Not Found error'
do
expect
{
subject
}.
to
raise_error
(
Gitlab
::
Graphql
::
Errors
::
ResourceNotAvailable
)
end
end
end
end
spec/support/shared_examples/requests/api/graphql/mutations/boards/update_list_shared_examples.rb
0 → 100644
View file @
b7fa6599
# frozen_string_literal: true
RSpec
.
shared_examples
'a GraphQL request to update board list'
do
context
'the user is not allowed to read board lists'
do
it_behaves_like
'a mutation that returns a top-level access error'
end
before
do
list
.
update_preferences_for
(
current_user
,
collapsed:
false
)
end
context
'when user has permissions to admin board lists'
do
before
do
group
.
add_reporter
(
current_user
)
end
it
'updates the list position and collapsed state'
do
post_graphql_mutation
(
mutation
,
current_user:
current_user
)
expect
(
response
).
to
have_gitlab_http_status
(
:success
)
expect
(
mutation_response
[
'list'
]).
to
include
(
'position'
=>
1
,
'collapsed'
=>
true
)
end
end
context
'when user has permissions to read board lists'
do
before
do
group
.
add_guest
(
current_user
)
end
it
'updates the list collapsed state but not the list position'
do
post_graphql_mutation
(
mutation
,
current_user:
current_user
)
expect
(
response
).
to
have_gitlab_http_status
(
:success
)
expect
(
mutation_response
[
'list'
]).
to
include
(
'position'
=>
0
,
'collapsed'
=>
true
)
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